newline

TIL: reader mode in Google Docs/Slides/Sheets

TIL

April 28, 2020

Sometimes, you just want to read a Google document, and in those cases the UI might be overwhelming. It definitely is for me. The good news is you can easily get rid of that UI by replacing the /edit in the URL with /preview. And you can automate it with a simple bookmarklet.

By default when you open a Google document, you get the whole UI. This can look pretty busy, especially when all you want to do is read the document:

Example of a busy Google Doc

The end of the URL generally contains the string /edit. If you replace this with /preview, you get a much cleaner looking document, perfect for reading:

Example of a Google Doc in reader mode

See for yourself: here’s a public document before and after changing the URL. This also works for Google Sheets (before, after) and Slides (before, after)!

Although this is nice, it would be a bit tedious to edit the URL manually every time, so let’s write some Javascript code for a bookmarklet:

(function(){
  if (["docs.google.com", "sheets.google.com", "slides.google.com"].includes(document.location.host) && document.location.href.match(/\/edit[^\/]*$/)){
    window.location.href = document.location.href.replace(/\/edit[^\/]*$/, "/preview");
  };
})()

Granted, it’s not the most beautiful code ever, but bookmarklets are rarely beautiful since everything gets smooshed into one line anyway. The code is an immediately invoked function expression (IIFE). It first checks whether the page is a Google Doc, Slide, or Sheet. Then, it checks whether the URL ends with /edit, potentially followed by some parameters. If both of these conditions are true, it replaces everything from /edit to the end of the URL with /preview, and redirects to this new URL.

If you want, you can save this code as a bookmark, prepended with javascript: (so like javascript:(function(){...). You can also just drag this link to your bookmarks bar. Now if you visit a Google Doc, Sheet, or Slide and click the bookmark, you’ll be redirected to the same document, but in the cleaner “reader mode”.