How to turn HTML into a QR code

A QR code cannot hold a page. It holds an address, which is better, because the address can serve something you are still editing.

To get from HTML to a QR code, put the page at an address first and encode that address, because a QR code carries a short piece of text rather than a file.

That single sentence is the whole answer, and it is the step most people skip. They open a QR generator, look for a place to upload an .html file, and find none.

A phone camera reading a QR code. What it decodes is a line of text, in this case an address.
A phone camera reading a QR code. What it decodes is a line of text, in this case an address.

Why the file cannot go in the code

A QR code stores text. Version 40 at the lowest error correction holds roughly 2,900 bytes of raw data, which sounds like enough for a small page until you look at what a real page weighs.

A styled report with a chart runs to tens of kilobytes before images. Even a page that fits produces a grid so fine that phone cameras cannot resolve it from arm's length.

There is a second problem that size does not explain. Most camera apps decode the text and then decide what to do with it. An address becomes a tappable link. A block of raw markup becomes a wall of text on screen.

What you encode What the scanner does Practical result
A short https address Offers to open it The page appears
A data URI containing the page Sometimes shows the text, sometimes nothing Unreliable
A file:/// path Nothing useful Fails on every other device
Plain text of the markup Displays the code The reader sees source, not a page

The top row is the only one that works on an unfamiliar phone, which is the only test that matters for a printed code.

How to convert HTML to a QR code in four steps

  1. Check the page stands on its own. Open the file in the HTML file opener, a window that has never seen your project folder. Styling and images that survive there will survive on a stranger's phone. If not, fold them in with self-contained HTML.
  2. Give the HTML an address. Paste the markup into a NOS document. It renders exactly as written, dark theme, charts and scripts included, as a page of its own. Turning HTML into a link is this step on its own page.
  3. Create the share link. Share, then Share link, then Create link. The link is unlisted by default, meaning it opens for whoever has it but is not listed anywhere. Tick Public on the web if the page should turn up in search.
  4. Encode the link. Paste the address into whatever QR generator you use, then scan the result once on a real phone before anything goes to print.
Step two: the HTML pasted into a NOS document, rendering as a page.
Step two: the HTML pasted into a NOS document, rendering as a page.

A link in a chat message can be replaced. A code on a banner cannot. That difference drives three decisions.

The address must be stable. If your route to hosting is uploading a file, every correction risks a new path, and the printed code points at the old one. A document that keeps its address while the content changes removes that risk.

The page must work on a phone. Every scan arrives on a small screen. Check the viewport meta tag is present, or the page renders at desktop width and the reader sees a corner of it.

The size on paper must match the distance. A rough print rule is that the code should be about a tenth of the distance it is scanned from. A code read from two metres wants to be around twenty centimetres wide.

The shared page open on a phone, at the width the scanner will see it.
The shared page open on a phone, at the width the scanner will see it.

Where the address comes from

You have the usual choices, and they differ mainly in what a correction costs.

Route Address stable after an edit Cost of a correction
NOS document Yes Click the text, fix it, done
Static host, same filename Yes Re-upload, clear caches
Static host, new filename No The printed code is dead
A file on your own machine Not an address at all Nothing to scan

Static hosting compared with a document goes through the trade in more detail. For printed codes the deciding factor is usually that nobody wants to reprint a hundred handouts because a date changed.

A shortener adds a redirect you control, which is useful when the destination genuinely might move. It also adds a second service that has to stay alive for your printed code to work.

If the underlying address is already stable, the shortener buys you little. If you need scan counts, it buys you that, at the cost of the dependency.

Either way, encode the final address you will keep. A code made from a preview link or a temporary path is a code you will regret.

Before the code goes out

  • Scan it with a phone that has never opened the page, on mobile data rather than office wifi.
  • Confirm the destination is the current version, not a draft copy.
  • Check the page has a <title>, since some scanners show it in the confirmation prompt.
  • Print a test at the real size, on the real material, and scan from the real distance.
  • Decide whether the content should be public or unlisted before anyone scans it.
The Share link panel, where the address that goes into the code is created.
The Share link panel, where the address that goes into the code is created.

The code itself is the trivial part. Everything that makes a printed QR code fail is upstream of it, in whether the page has a permanent address and whether it reads on a small screen.

Questions people ask

Can a QR code contain an entire HTML page?

In theory a QR code can hold a couple of kilobytes of text, and a data URI containing HTML is text. In practice the code becomes a dense grid that phone cameras struggle to read, and most scanner apps will not render raw HTML they decode. Encode a link instead.

What do I encode if the file only lives on my laptop?

Nothing useful. A file path such as file:///Users/you/report.html means something only on your machine, so the scan fails on every other device. The page needs an address on the web before a code is worth printing.

Will the QR code stop working when I edit the page?

Not if the address stays the same. A NOS document keeps its address while you edit the content, so a printed code keeps pointing at the current version. Re-uploading a file to a new path is what breaks printed codes.

Should the link be public or unlisted?

A code printed on a poster is effectively public, since anyone can scan it. A code on a handout for one room can stay unlisted, which keeps it out of search results. Treat unlisted as unlisted, not as a password.

Keep reading