---
title: "json formatter and repair tool - codefmt"
url: https://codefmt.dev/json
updated: 2026-08-24
sources:
  - https://codefmt.dev/json
licence: "© codefmt. Cite with attribution to https://codefmt.dev."
---

# json formatter and repair tool

codefmt's JSON tool formats, validates, and repairs JSON in the browser with exact line and column error positions. it reprints numbers from your source text instead of parsing them into floats, so 19-digit ids and trailing-zero decimals survive formatting unchanged. documents up to 5MB format instantly, entirely client-side.

## what the tool does

- reports the exact position of the first syntax error, with an inline squiggle and a go-to-error jump
- repairs almost-JSON on request: comments, trailing commas, single quotes, unquoted keys, Python literals, undefined
- preserves duplicate keys and exact number digits (no JSON.parse round trip)
- offers 2-space, 4-space, tab, and minified output, key sorting, and a tree view with copy path and copy value
- detects Zapier, n8n, Pipedream, and HubSpot webhook payloads and generates access code for them

## frequently asked questions

### why did my large JSON number change?

if it changed, JavaScript's JSON.parse changed it. JSON.parse stores every number as a 64-bit float, and floats are only exact for integers up to 9,007,199,254,740,991 (2^53 - 1). a 19-digit id like 1144241312345678901 silently rounds to 1144241312345678800, and a decimal written as 1.10 comes back as 1.1. codefmt doesn't parse numbers into floats: it reprints each number's original digits straight from your source text, so ids and decimals survive formatting unchanged.

### what does repair fix?

repair fixes six categories of almost-JSON: comments (// and /* */), trailing commas, single-quoted strings, unquoted object keys, the Python literals True, False, and None (rewritten to true, false, and null), and JavaScript's undefined (rewritten to null). it also strips a leading byte-order mark and notes it. repair is opt-in and off by default because it rewrites your input. when it runs, a notice above the output lists exactly what changed, for example: repaired: 2 trailing commas, 1 unquoted key.

### is my JSON uploaded to a server?

no. formatting, repair, tree view, and payload detection all run in your browser; nothing you paste leaves the page. that makes it safe for webhook payloads that contain api keys, tokens, or customer data. documents up to 5MB format instantly; past that limit formatting pauses so the page stays responsive.

### why are there two identical keys in the formatted output?

because your input had two. codefmt formats from the raw tokens of your document, so duplicate keys are preserved exactly as written. a JSON.parse round trip keeps only the last value for any repeated key, which hides the duplicate instead of showing it. preserving duplicates means the formatted output matches the document you pasted, mistakes included, and a duplicate key is usually a mistake worth seeing.

### how do I find where my JSON is invalid?

paste it. the parser reports the exact line and column of the first problem, draws an inline squiggle under it in the editor, and the error banner's go to error button jumps your cursor straight to the spot. if the input looks repairable, the same banner offers a one-click enable repair action.

### can I minify JSON instead of pretty-printing it?

yes. the indent control offers 2-space, 4-space, tab, and minify output. minify strips all insignificant whitespace, which is useful for embedding JSON in an environment variable or a query string. you can also sort keys alphabetically, and the text or tree toggle switches the output pane between a code view with line numbers and an expandable tree with copy path and copy value on every node.

## for agents and automation

- format API: POST https://codefmt.dev/api/format (OpenAPI: https://codefmt.dev/api/openapi.json, 50KB max code, no authentication)
- MCP server: POST https://codefmt.dev/api/mcp (tools: format_code, format_json, ask_codefmt)
- site index for agents: https://codefmt.dev/llms.txt
- scoped context file: https://codefmt.dev/json/llms.txt
