PlayTools

JSON formatter: readable data, fewer production bugs

문법 강조와 오류 감지로 JSON을 서식 정리, 검증, 압축합니다. 브라우저에서 완전 실행.

Runs in your browser — nothing you enter is uploaded

JSON formatter: readable data, fewer production bugs

JSON is the lingua franca of modern APIs. Pretty-printing exposes missing commas, mismatched braces, and accidental trailing text. Minifying removes whitespace for bandwidth while keeping payloads valid for clients that reject pretty output.

When to validate here: pasting sample responses from logs, preparing fixtures for tests, or teaching newcomers how objects and arrays nest. The linter feedback is immediate and private—nothing uploads to a server in normal browser-only operation.

Privacy tip: large JSON may contain tokens or PII — scrub secrets before sharing screenshots. Pair with Base64 or URL tools when debugging encoding layers.

Edge cases: duplicate keys are technically invalid per RFC but some parsers last-wins; JSON cannot have comments unless your pipeline uses JSON5—don’t assume comments are portable.

Workflow: format → visually scan structure → minify only when sending over the wire. Keep canonical pretty copies in repos for code review readability.

What Format and Minify actually do

Both buttons parse your input with the browser’s built-in JSON parser and write it back out — with 1, 2 or 4 spaces of indentation for Format, or with no whitespace at all for Minify. If the input is not valid JSON, nothing is rewritten and the parser’s error message is shown instead. Because the output is regenerated from the parsed data rather than edited in place, a few things change in ways worth knowing:

  • Duplicate keys: {"k":1,"k":2} becomes {"k":2}. The last value wins silently and the earlier one is dropped — a common source of “my setting is ignored” bugs.
  • Big integers lose precision: 12345678901234567890 becomes 12345678901234567000, because numbers are stored as 64-bit floating point and only integers up to 9,007,199,254,740,991 are exact. Send large IDs as strings.
  • Number spelling is normalised: 1.0 becomes 1 and 1e3 becomes 1000 — the same values, written differently.
  • Integer-like keys move first: {"b":1,"2":0,"a":2,"1":0} comes out as {"1":0,"2":0,"b":1,"a":2}. Other keys keep their original order.
  • Escapes are decoded: "caf\u00e9" is written back as "café".

Worked example: fixing invalid JSON

This looks like JSON but is rejected:

{
  'name': "Ada",
  "langs": ["en", "fr",],
  "active": True
}

Three problems: property names and strings need double quotes, a comma is not allowed after the last item in an array or object, and the literals true, false and null must be lowercase. The corrected version formats cleanly, and minified it becomes {"name":"Ada","langs":["en","fr"],"active":true} — 48 characters instead of 74 with 2-space indentation.

Minifying saves more as nesting grows: a three-user sample with ids, names, roles and an active flag goes from 412 characters pretty-printed to 203 minified. Over HTTP, gzip or Brotli compression narrows that gap considerably, so readable JSON in config files and fixtures costs very little.

Reading the error message

Error messages come from your browser, so the wording varies, but current Chrome and Edge report a position and a line and column, for example “Expected property name or '}' in JSON at position 4 (line 2 column 3)”. Position counts characters from zero. The real mistake is usually at that point or just before it — often a missing comma or quote on the previous line.

“Unexpected non-whitespace character after JSON” means there is more than one value in the input, such as two objects one after another. That is how NDJSON (newline-delimited JSON) log files are written; format one line at a time.

JSON, JSONC, JSON5 and NDJSON

  • JSON (RFC 8259): what this tool accepts — no comments, no trailing commas, double quotes only.
  • JSONC: JSON with // and /* */ comments, used by tsconfig.json and VS Code settings. Remove the comments before validating here.
  • JSON5: a looser superset allowing single quotes, unquoted keys, trailing commas and hexadecimal numbers. Fine for hand-edited config if your tooling supports it; not interchangeable with JSON APIs.
  • NDJSON / JSON Lines: one complete JSON value per line, common for logs and data exports. Each line is valid JSON on its own; the file as a whole is not.

Choosing an indentation

Two spaces is the convention in JavaScript projects (package.json, most API documentation) and keeps deep nesting readable on narrow screens. Four spaces matches Python’s json.dumps(indent=4) and many Java style guides. One space is a compromise for files that are diffed often but still read by humans. Pick one per repository and let your formatter enforce it, so reviews show real changes rather than whitespace.

In-depth guides

These free tools pair well with this page — open them in a new tab to finish your workflow.

자주 묻는 질문

'포맷'과 '최소화'는 JSON에 어떤 작업을 하나요?

포맷(예쁘게 출력)은 공백, 들여쓰기, 줄 바꿈을 추가하여 JSON을 사람이 읽기 쉽게 만듭니다. 최소화는 불필요한 공백을 모두 제거하여 가장 간결한 형태로 만들어 API 응답의 대역폭을 절약합니다.

왜 JSON 검증이 실패하나요?

일반적인 JSON 오류: 마지막 키/값 쌍 뒤의 후행 쉼표(JSON 불허), 문자열에 단따옴표 사용(쌍따옴표 필수), 따옴표 없는 속성 이름, 선행 0이 있는 숫자 등. 이 유효성 검사기는 오류 위치를 강조 표시합니다.

JSON과 JavaScript 객체의 차이점은 무엇인가요?

JSON은 JavaScript의 엄격한 부분 집합인 데이터 교환 형식입니다. 주요 차이점: JSON 속성 이름은 쌍따옴표로 묶인 문자열이어야 함; 값에 undefined, 함수, 심볼 불가; 주석 불허.

JSON에 주석을 포함할 수 있나요?

아니요. JSON 사양(RFC 8259)은 주석을 허용하지 않습니다. 설정 파일에 주석이 필요하다면 JSON5, HJSON, YAML을 고려하세요.

JSON Schema란 무엇인가요?

JSON Schema는 JSON 문서의 구조와 내용을 검증할 수 있게 해주는 어휘 규격입니다. 필수 속성, 허용 유형, 값 범위 등의 규칙을 정의할 수 있습니다. API 계약 검증과 폼 입력 검증에 사용됩니다.