{"slug": "show-hn-fastest-non-lossy-json-parser", "title": "Show HN: Fastest non lossy JSON parser", "summary": "Best JSON Formatter 0.2.0, a non-lossy JSON parser and formatter that preserves duplicate keys, integer precision, and exact token spelling, is the fastest fully lossless formatter in benchmarks, outperforming Biome 2.5.6, Prettier 3.9.6, and jsonc-parser 3.3.1 on files up to 5.35 MB. The tool runs locally via npx or the bjf CLI, requires Node.js 20+, and includes commands for validation, formatting, repair, conversion, and schema operations.", "body_md": "Fast, local JSON formatting and correctness checks without lossy\n`JSON.parse()`\n\n/`JSON.stringify()`\n\nround trips.\n\n```\nnpx -y bestjsonformatter@latest check response.json\nnpx -y bestjsonformatter@latest format response.json --write\n```\n\nBest JSON Formatter preserves duplicate object properties, integers beyond JavaScript's safe range, decimal and exponent spelling, string escape spelling, and property order. It performs no network requests, collects no analytics, and requires no MCP server or account.\n\nUse it without installing:\n\n```\nnpx -y bestjsonformatter@latest check package.json\n```\n\nOr install the short `bjf`\n\ncommand:\n\n```\nnpm install --global bestjsonformatter\nbjf check package.json\n```\n\nNode.js 20 or newer is required.\n\n`check`\n\nvalidates syntax and finds duplicate keys and numbers that ordinary JavaScript parsing may\nround, overflow, underflow, or rewrite:\n\n```\nbjf check response.json\nbjf check response.json --json\nbjf check response.json --schema response.schema.json\n```\n\nExit codes are stable for CI and coding agents:\n\n| Code | Meaning |\n|---|---|\n`0` |\nValid JSON with no selected correctness findings |\n`1` |\nInvalid JSON, correctness findings, schema errors, or formatting differences |\n`2` |\nInvalid command, inaccessible file, or internal failure |\n\n```\nbjf format response.json\nbjf format response.json --check\nbjf format response.json --write\nbjf format response.json --indent minified\nbjf format response.json --indent tab\nbjf format response.json --sort\n```\n\nOrdinary formatting changes whitespace only. `--sort`\n\nexplicitly reorders object properties while\npreserving array order and exact scalar tokens. `--write`\n\nuses a same-directory temporary file and\natomic rename.\n\nMultiple files are supported when checking or writing:\n\n```\nbjf format package.json fixtures/*.json --check\nbjf format package.json fixtures/*.json --write\nbjf check fixtures/*.json --json\nbjf repair broken.json\nbjf repair broken.json --write\nbjf duplicates response.json\nbjf precision response.json\nbjf compare before.json after.json\nbjf query '$.items[*].id' response.json\nbjf to-yaml response.json\nbjf to-csv records.json\nbjf to-xml response.json\nbjf schema-infer response.json\nbjf schema-validate response.json schema.json\nbjf schema-sample schema.json\n```\n\nRepair output is a proposal unless `--write`\n\nis explicitly supplied. Use `-o output.ext`\n\nto write\nconversion or repair output to a separate file.\n\nAgents can call the CLI directly through their normal shell, so JSON never has to be copied into an MCP tool argument or model context.\n\nInstall the agent skill:\n\n```\nnpx skills add skrcode/bestjsonformatter-cli\n```\n\nThe skill teaches Codex, Claude Code, Cursor, GitHub Copilot, and other compatible agents to run\ncompact checks first and request explicit authorization before `--write`\n\n.\n\nThe same engine is available as an ESM library:\n\n``` js\nimport { checkJson, formatLosslessJson } from \"bestjsonformatter\";\n\nconst checked = checkJson(source);\nconst formatted = formatLosslessJson(source, 2).formatted;\n```\n\nHeavy repair, diff, query, conversion, and schema dependencies are loaded only when their operations are requested. Formatting, validation, and correctness checks stay on the small local hot path.\n\nIn the repository's reproducible five-run benchmark, Best JSON Formatter is the fastest formatter that passes every exact-token check.\n\n| Fresh-process median | 155 B | 105 KB | 1.07 MB | 5.35 MB | Fully lossless |\n|---|---|---|---|---|---|\n| Best JSON Formatter 0.2.0 | 54 ms |\n76 ms |\n143 ms |\n473 ms |\nYes |\n| Biome 2.5.6 | 58 ms | 88 ms | 280 ms | 1,150 ms | No |\n| Prettier 3.9.6 | 120 ms | 234 ms | 955 ms | 3,926 ms | No |\n| jsonc-parser 3.3.1 | 63 ms | 825 ms | >15,000 ms | >15,000 ms | Yes |\n| jq 1.8.2 | 5 ms | 14 ms | 105 ms | 500 ms | No |\n\nThe comparison uses identical stdin payloads and complete fresh CLI processes. jq is faster on\nsmall and one-megabyte inputs but discards duplicate keys and rewrites number and escape spelling.\nResults are bounded to the recorded machine, versions, inputs, and command boundaries—not a\nuniversal speed claim. See [the complete method, raw samples, Python and native Node\nresults](/skrcode/bestjsonformatter-cli/blob/main/docs/BENCHMARKS.md).\n\nDocuments are read and processed inside the local Node.js process. The package contains no telemetry client, post-install script, network request, account system, or hosted document API.\n\n```\nnpm install\nnpm run check\nnpm run benchmark\n```\n\nEvery formatting change must preserve the exact-token fixtures. Performance changes must record the complete journey, competitor versions, raw samples, median, p95, correctness, and timeouts.\n\nMIT licensed. The browser tool is available at\n[bestjsonformatter.org](https://bestjsonformatter.org).", "url": "https://wpnews.pro/news/show-hn-fastest-non-lossy-json-parser", "canonical_source": "https://github.com/skrcode/bestjsonformatter-cli", "published_at": "2026-07-28 18:23:14+00:00", "updated_at": "2026-07-28 18:52:27.868516+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["Best JSON Formatter", "Biome", "Prettier", "jsonc-parser", "jq", "Node.js"], "alternates": {"html": "https://wpnews.pro/news/show-hn-fastest-non-lossy-json-parser", "markdown": "https://wpnews.pro/news/show-hn-fastest-non-lossy-json-parser.md", "text": "https://wpnews.pro/news/show-hn-fastest-non-lossy-json-parser.txt", "jsonld": "https://wpnews.pro/news/show-hn-fastest-non-lossy-json-parser.jsonld"}}