by JSONBeauty (LX AI)
I work on micro‑services that exchange JSON over HTTP. When a payload arrives minified it is a wall of text. I need to see the structure quickly, and when the payload is broken I need to know exactly where the parser choked. Existing online formatters either hide the error or require uploading data to a third‑party site. I wanted a tool that runs locally, shows a clean indented view, and points to the offending character with line and column numbers.
The core is a thin wrapper around the built‑in JSON.parse in Node and the browser. I first attempt to parse the string. If it succeeds I run a recursive pretty‑printer that inserts line breaks and a two‑space indent. If parsing fails I catch the exception, extract the offset reported by the engine, and translate that offset into a line/column pair. The output then shows the original text with a marker under the problematic character and a short message.
I rely on the engine’s own parser because it is battle‑tested and follows the ECMAScript specification. This means I inherit the same error locations that JSON.parse provides, which are accurate for the vast majority of malformed inputs I have seen in the wild.
When JSON.parse throws, the exception object contains a message string and, in V8‑based engines, a stack that includes the character index. I parse that index, count newline characters to get the line number, and compute the column as the distance from the line start. I then slice the original string into three parts: before the error, the offending character, and after the error. I wrap the offending character in a <strong> tag for visual emphasis.
The formatter walks the parsed value depth‑first. For objects it prints each key on its own line, adds a colon, a space, then the formatted value. For arrays it prints each element on its own line. Indentation increases by two spaces for each nesting level. Strings are output with double quotes and escaped as needed. Numbers, booleans and null are printed literally.
JSONBeauty ships as a single binary jsonbeauty that works on macOS, Linux and Windows. It reads from stdin or a file path and writes to stdout unless you specify an output flag.
Download the pre‑built archive from the releases page, extract the binary, and place it somewhere on your PATH. No Node installation is required because the binary bundles the runtime.
jsonbeauty < payload.json
If the input is valid you will see a nicely indented version. If it is invalid the program prints an error line like:
Error at line 12, column 7: unexpected token '}'
-t 4 sets a tab size of four spaces.-c colors the error marker red in terminals that support ANSI.-o outfile.txt writes the result to a file instead of stdout.For quick checks I provide a tiny script that you can drop into any page. It adds a textarea, a button and a preview pane. The widget runs entirely in the client, so no data leaves your machine.
Add the following line before the closing </body> tag:
<script src="https://unpkg.com/jsonbeauty@latest/dist/widget.js"></script>
Paste or type JSON into the left textarea. As you type the widget attempts to parse on each keystroke. If the text is valid the right pane shows the pretty‑printed version with two‑space indent. If it is invalid the pane shows the original text with a red underline under the first offending character and a tooltip with line/column.
A button beneath the preview copies the formatted output to the clipboard. The widget also offers a “Download” link that saves the pretty‑printed text as a file with a .json extension.
I use JSONBeauty in my test pipelines to catch malformed responses early. The tool can be invoked as a step in a shell script or as a Node module.
Before sending a request I sometimes need to ensure a JSON payload I constructed is well‑formed. I pipe the payload through JSONBeauty and check the exit code. A non‑zero exit means I have to fix the source before the request goes out.
After receiving a response I pipe the body through JSONBeauty. If the service returns valid JSON I get a readable log entry. If the service returns broken JSON I get an error line that I can attach to a bug report.
In a long‑running service I redirect stderr to a log file. JSONBeauty’s error messages include a timestamp when invoked from a wrapper script, making it easy to correlate malformed inputs with specific requests.
Below is a simple comparison of runtime for different input sizes on my laptop (Node 20, Chrome 124). Times are wall‑clock averages of ten runs.
| Payload size | Node (ms) | Browser (ms) |
|---|---|---|
| 10 KB | 2.3 | 1.9 |
| 100 KB | 4.1 | 3.6 |
| 1 MB | 12.8 | 11.4 |
| 5 MB | 68.5 | 62.0 |
I want to be clear about the limits of JSONBeauty so you do not rely on it for things it was not designed to do.
The tool only checks syntactic validity. It will not tell you if a required field is missing, if a number is out of range, or if a date string does not match the expected format. Those checks belong in a schema validator or unit tests.
If you need to validate against a JSON Schema draft you should use a dedicated library such as AJV (https://ajv.js.org/json-schema.html). JSONBeauty does not evaluate keywords like required, minimum or pattern.
Automated tests should assert the shape and meaning of your data. JSONBeauty is a convenience for manual inspection and quick sanity checks, not a substitute for a test suite.
I keep a written checklist next to every release that touches this topic. The list is boring on purpose: name the owner, name the evidence artifact, and name the rollback. If a step cannot produce a file, a ticket, or a log line, it is not a step — it is a wish.
| Signal | What to record | Stop-ship? |
|---|---|---|
| Unexpected write or send | Tool name, args, identity | Yes until gated |
| Missing confirmation on destructive action | Call path and bypass | Yes |
| Untrusted text treated as instruction | Source surface and resulting action | Yes for agent reach |
| Scanner clean, judgment open | Deferred items + owner | Only if core path safe |
jsonbeauty helps with the measurable first pass. Architecture choices, legal sign-off, and customer-facing claims still need a human owner. Treat every checklist row as decision support, not a certificate.
When a prospect asks whether the product "covers everything," I answer with the boundary: automated checks catch known patterns; novel chains and policy judgment still need review. That honesty keeps support load down and keeps the blog aligned with what the product actually does.
If you need a second opinion, pair this write-up with the references below and with your own staging reproduction. Do not skip the reproduction step just because a model wrote a confident summary.
Minified API payloads are unreadable. JSONBeauty formats them or tells you where the parse failed.
Want to try the product? JSONBeauty
Generated 2026-09-17 · primary sources only · no fabricated traffic metrics