Browser hack for Dark Mode in PDFs! 🦉

Dear dark mode lovers,

In this article I present a hack to view PDFs in dark mode on any browser! 🔥

To get started, open any PDF in your favorite browser. Then open the dev tools by using the shortcut ctrl + shift + I or f12 and run one of the following in the console based on your browser:

New Microsoft Edge/Google Chrome/Brave/Opera

js
1document.embeds[0].style.filter = 'invert(0.95)';

Firefox

js
1document.getElementById('viewerContainer').style.filter = 'invert(0.95)';

This is the original image: Original Image

Here is the result after running the script: Dark Mode

💡 You can change 0.95 to any number between 0 and 1.

If you found this useful, like the post and share it with your friends!

Tags:

MindsDB

Machine Learning

MongoDB

MongoDB Atlas

Share article
Aditya DS © 2025