Invert PDF Colors (Dark Mode PDF)

Turn a PDF into a dark mode PDF for night reading. Invert page colors to light text on a dark background, with a smart mode that spares photos.

🌐 Español

Drop your file here (.pdf)

🔒 Private by design: your files are processed locally in your browser and never uploaded to any server.

Dark mode that travels with the file

Plenty of PDF readers offer a night mode, and for a single device it is the easier answer. The catch is that it is a viewing filter. It lives in that app’s settings, applies while you look at the page and is gone the moment the document is opened somewhere else, emailed to a colleague, loaded onto an e-reader that has no such setting, or printed.

Inverting the file writes the change into the document. A white page with black type becomes a dark page with light type in every viewer, on every device, permanently, because the pages have genuinely changed rather than being recolored on their way to the screen. That is a strange thing to want for an archival document and exactly the right thing for the copy of a textbook chapter you read in bed.

The arithmetic itself is trivial. Each red, green and blue channel is replaced by 255 minus its old value, the same helper that powers invert-image for photographs. What makes a document harder than a photograph is that a blind inversion also flips every picture on the page into a negative, and a page of otherwise readable notes with a livid blue face staring out of it is worse than the bright original.

Inside smart mode: operator lists, matrices and unit squares

A PDF page is a program. It places an embedded image by building up a transformation matrix through a sequence of transform operators, then painting the image into the unit square, which the matrix stretches and moves into position. Smart mode replays that program without drawing anything, keeping a stack for the save and restore operators so nested transforms unwind properly, and every time an image painting operator appears it takes the current matrix, pushes the four corners of the unit square through it, then through the renderer’s own page to pixel matrix, and records the box that encloses them.

That is computed from the document’s own placement data rather than guessed from what the pixels look like, which is why a night sky and a beach are found the same way. It is exact for an image the page places directly; one nested inside a reusable form object that carries its own matrix is located from the page level placement alone, so its box can land beside the picture rather than on it, and because that object’s own transforms are not unwound when it ends, a later picture on the same page can be shifted too. The page is then inverted in full, and each of those recorded rectangles is copied back from a snapshot taken before the inversion, which is why a photo comes out looking normal while the paper around it goes dark.

The boundaries are rounded outward rather than to the nearest pixel. That choice guarantees an image never loses its own edge row, at the cost of occasionally carrying a hairline of surrounding page into the protected box.

Two image operators that stay inverted on purpose

Not every image on a page is a photograph, and two cases are deliberately left out of the detection rather than half handled.

The first is the stencil mask, a one bit image painted in the current fill color. Scanned monochrome text and many logos arrive this way, and because such an image takes its color from the graphics state it behaves like type rather than like a picture. Sparing it would leave black marks on a black background. It is inverted with everything else.

The second is the repeated image, a single picture tiled several times through a pattern fill, where each repetition carries its own transform inside an argument structure the detector does not unpack. It is rare, and when it does appear its content simply inverts along with the page instead of being reverse engineered.

Turning a document dark, one option at a time

  1. Drop your PDF onto the box above or press Choose a file. One document per run.
  2. Leave Keep photos & images un-inverted (smart mode) ticked, which is the default, so pictures keep their real colors. Unticking it inverts the whole page with no exceptions, which is what you want for a document whose only images are diagrams that read better reversed.
  3. Set Output quality. Standard (150 DPI), recommended is ample for reading on a screen, Print quality (300 DPI), best for a professional print run doubles the linear detail and so quadruples the pixels, the memory and the time, and Smaller file (100 DPI) keeps a phone copy light.
  4. Press Invert PDF Colors (Dark Mode PDF) and watch the progress climb page by page, the last stretch being the assembly of the new document.
  5. Download the file, which arrives with -inverted added to the name, so notes.pdf becomes notes-inverted.pdf.

Picking a resolution for a screen you read in the dark

The resolution ladder is shared with grayscale-pdf, which renders through the same code, and the same reasoning applies with one twist. Reading happens on a screen, and a phone or tablet displaying a page at fit to width is nowhere near using the detail that Print quality produces, so Standard is usually the sharpest setting anyone will actually see.

Where the twist bites is compression. An inverted page is dominated by a large flat dark area, and every page is stored as a JPEG, so pushing the quality down to Smaller file puts the coarsest compression against the least forgiving background. If a dark page looks blotchy behind the text, that is the setting to raise first.

What an inverted copy is not good for

The pages you get back are pictures. The new document is assembled from scratch around those images, so selectable text, search, links, bookmarks, comments and form fields are all absent from it, and its page dimensions are the only thing carried over from the original. Treat the inverted file as a reading copy and keep the source for everything else.

A document that needs a password to open cannot be inverted here, because nothing in the tool ever asks you for one. A file carrying only an owner password, which restricts printing or copying rather than opening, is read with the empty password and inverts normally. If the finished file is heavier than you want on a phone, the pages are already images, so the lossless clean up in compress-pdf has little left to strip and its strong mode, which re-renders the pages, is the one that helps. And if what you actually wanted was dark slides rather than a dark document, run the inverted file through pdf-to-jpg to get one image per page, with the rest of the workflow waiting in the PDF tools.

See it in action

Screenshot of the Invert PDF Colors (Dark Mode PDF) tool with sysfenix-sample.pdf (3 KB) loaded, Keep photos & images un-inverted (smart mode) set to on, Output quality set to Standard (150 DPI), recommended
Invert PDF Colors (Dark Mode PDF) mid-process: sysfenix-sample.pdf (3 KB) loaded, Keep photos & images un-inverted (smart mode) set to on, Output quality set to Standard (150 DPI), recommended.
Screenshot of the Invert PDF Colors (Dark Mode PDF) result screen showing sysfenix-sample-inverted.pdf ready to download (193 KB, 7059% larger)
The finished result: sysfenix-sample-inverted.pdf ready to download (193 KB, 7059% larger). The download link is a local blob URL — the file never leaves your device.

Frequently asked questions

Does smart mode look at the colors to work out where a photo is?

No, and that is the reason it is reliable. It walks the drawing instructions the page itself contains, tracking the transformation matrix as it goes, and marks a rectangle wherever an image painting operator appears. A dark photograph of a night sky and a bright one of a beach are found the same way, because the detection never looks at a single pixel value.

A picture on my page sits at a slight angle and the area around it stayed light. Why?

Because the restored area is an upright rectangle. The four corners of the image are mapped into page coordinates and the box that encloses all of them is what gets put back, which for a rotated picture is larger than the picture itself and pulls in the triangles of background around it. The same rounding outward by a fraction of a pixel is what stops a straight image from ever losing its own edge.

Can I run the file through twice to get my original back?

The pixel arithmetic is its own opposite, since subtracting a value from 255 twice returns the value, but the file will not survive the trip. Each pass rasterizes every page at the resolution you chose and stores it as a JPEG, so a second run gives you roughly the original colors carrying two generations of rendering and compression. Keep the source document instead.

My scanned page inverted completely even with smart mode ticked. What happened?

Scans saved as one bit stencil images are handled as ordinary page content rather than as photographs, because that kind of image is painted using the current fill color and behaves exactly like text does. Full color and grayscale scans are detected and spared as expected. If a monochrome scan is what you have and you want it to stay light, this tool is the wrong one for that page.

Does smart mode cost time or memory?

Both, a little. It keeps a second untouched copy of the rendered page while the inverted version is being built, which for an A4 page at Print quality is around 33 MiB held twice, and it asks the renderer for the page's instruction list on top of drawing it. On a long illustrated document at 300 DPI that is the combination most likely to strain a phone, so drop to Standard if a run stalls.

Should I print the inverted copy?

You can, and the Print quality setting exists for the people who do, but think about the consumables first. A page that was mostly white is now mostly solid dark, so a home printer will pour toner or ink into every sheet and a copy shop will charge for the coverage. Inverting is aimed at screens.

Related tools