DEV Community

Joan Bernier
Joan Bernier

Posted on Edited on

How to Export a QR Code Payload as JSON in the Browser (Without Uploading the Screenshot)

A staging screenshot is a bad thing to drop into a random “online QR reader.” The image may include a checkout URL, an environment flag, a build id, or a blob of fixture data you would not want leaving the machine. The more useful move is to decode the codes locally and export the payloads as JSON or a plain-text dump you can diff, attach to a ticket, or inspect in an editor.

This walkthrough uses a fictional staging test page with two QR codes on it, then shows how to export qr code payload as json in the browser. The scanner is a tool we built at Pixoffline. It runs in the browser; the screenshot is not uploaded to our server. The page in the sample is not a real product, and the URLs are example.com placeholders.

The sample

The source image is a made-up “QR Test Page · staging” screen, 1440×900, with two codes side by side:

  1. A URL: https://example.com/staging/checkout?env=staging&build=demo-1234
  2. A raw JSON string: {"type":"demo","id":"DEMO-0001","env":"staging"}

Synthetic staging test page with two QR codes

A synthetic staging test page, not a screenshot of a real app.

Paste the screenshot and read both codes

Open the QR Code Scanner from Image page, copy the screenshot, and paste with Ctrl+V (Command+V on a Mac). The toolbar also has a Paste control.

In this demo, a single paste picked up both codes without a manual crop. The status bar reads “2 codes found”, with Multi-code on, and the image size 1440 × 900 px. Tabs at the top of the results list are labeled “#1 Website” and “#2 JSON.”

The first card is labeled “#1 · Website · QRCode”, with HTTPS “example.com” and the complete checkout URL “https://example.com/staging/checkout?env=staging&build=demo-1234”. The env=staging and build=demo-1234 parameters are visible before anyone follows the link. The second card is labeled “#2 · JSON · QRCode”, with the heading “JSON object · 3 keys” and the payload formatted as a three-key object (type, id, env). Its button is “Copy formatted JSON.”

QR scanner results showing a Website card and a JSON card

QR scanner showing two results: #1 Website and #2 JSON, with the full URL and formatted JSON.

The URL card’s buttons are “Open website” and “Copy URL”. The page does not navigate on its own. This sample has no tracking notice and no “Copy clean URL.”

Export JSON and TXT

The Export menu in the toolbar lists, in this order: “Copy all (2)”, “Download CSV”, “Download TXT”, and “Download JSON.” The files the tool writes are named qr-scan-results.json and qr-scan-results.txt.

Open the JSON file in a local text editor. The export is an array of two objects. Each object has these keys, taken from the real file: format, type, source, page, content, and position (with topLeft, topRight, bottomRight, and bottomLeft coordinates). format is “QRCode” on both. type is “url” on the first object and “json” on the second — those are the export’s lowercase values; the result cards themselves say Website and JSON. source is “image.png”, which is the default name the tool gives a pasted clipboard image. page is 1. content holds the full payload as a string: the checkout URL on the first object, and the JSON as an escaped string (not parsed into a nested object) on the second: {"type":"demo","id":"DEMO-0001","env":"staging"}.

Export menu listing Copy all, CSV, TXT and JSON downloads

Export menu with Copy all (2), Download CSV, Download TXT, and Download JSON.

Exported qr-scan-results.json open in a text editor

The exported qr-scan-results.json opened in a local text editor (Mousepad).

The TXT export is the simpler dump, useful when you want to search or diff payloads without parsing JSON. The real file is laid out as two blocks:

[1] (QRCode · Website)
https://example.com/staging/checkout?env=staging&build=demo-1234

[2] (QRCode · JSON)
{"type":"demo","id":"DEMO-0001","env":"staging"}
Enter fullscreen mode Exit fullscreen mode

There is a screenshot of the JSON file open in a local text editor (Mousepad). There is no separate editor screenshot of the TXT file; the layout above is copied from the exported .txt itself.

Hex and the code inspector

Expand “Code inspector & actions” on the JSON card. It shows Symbology QRCode, Version 4, Error correction M, Payload size 48 bytes, and Orientation 0°. The hex bytes are the straight ASCII encoding of the JSON string {"type":"demo","id":"DEMO-0001","env":"staging"}:

7b 22 74 79 70 65 22 3a 22 64 65 6d 6f 22 2c 22 69 64 22 3a 22 44 45 4d 4f 2d 30 30 30 31 22 2c 22 65 6e 76 22 3a 22 73 74 61 67 69 6e 67 22 7d

The inspector also has an “Edit & regenerate in QR Generator” action.

Code inspector showing the hex bytes of a QR payload

Code inspector showing hex bytes of a QR payload.

That hex pane is the quickest way to confirm that what you exported is exactly what was in the code, with no missing query parameter and no truncated JSON.

What to look at in the two payloads

The two codes in the sample are different on purpose. The first is a URL with query parameters. When you export it, confirm that env and build are still present and were not trimmed. If a real staging capture used a shortener, you would see that host instead of the checkout path, which is the point of reading the payload before anyone opens it.

The second code is not a URL at all. It is a JSON string that happens to live inside a QR symbol. Some readers will try to treat every payload as a link; you want the export to keep the braces, quotes, and keys intact. In the exported JSON file, that payload is stored in content as a single escaped string, not parsed into a nested object. Those two shapes are not the same when you write a test fixture around the file. The result card, by contrast, displays it as a formatted three-key object.

If the inspector’s hex view matches the characters you see in the editor, the export is a faithful copy of the symbol. If they disagree, trust neither until you re-scan.

Why this is handy in a test repo

  • You can attach the JSON export to a bug report instead of pasting a cropped screenshot and hoping the next person can scan it.
  • You can tell a staging checkout link from a production one by reading the URL first.
  • A fixture encoded as a JSON string is visible as data, not as a mystery graphic.
  • The image and the payloads stay on the machine running the browser.

A few limits to keep in mind: results can remain in the page’s local scan history (the clock icon in the toolbar) until you clear them. On a shared computer, use “Scan history” and “Clear all”, or turn off “Remember scans locally.” This sample did not need the toolbar’s Scan region control; it is there if a screenshot is too tight on a code.

If you want to try the same sequence on your own staging captures, the tool is at the link above. Use a page you are allowed to screenshot, and keep fixture data on your own machine.

Top comments (0)