JSON Editor

Edit and normalize JSON quickly for engineering and security workflows.

About this tool

The JSON Editor combines four operations in a single editing workflow: validate (check syntax), prettify (add indentation), minify (remove whitespace), and sort keys (alphabetical recursive sort). Unlike a pure formatter, the editor lets you modify JSON inline and apply operations directly to the edited content. It is designed for cleaning up API payloads, normalizing config files before committing, and preparing JSON for code review or comparison.

Real example

Start with a minified API response payload:

{"service":"odt","env":"prod","settings":{"debug":false,"retries":3}}

Click Prettify to expand:

{
  "service": "odt",
  "env": "prod",
  "settings": {
    "debug": false,
    "retries": 3
  }
}

Click Sort Keys to alphabetize (useful before running a diff to avoid key-order noise):

{
  "env": "prod",
  "service": "odt",
  "settings": {
    "debug": false,
    "retries": 3
  }
}

Nested keys are sorted recursively - settings sub-keys are sorted too.

Common use cases

  • API response debugging: Paste raw JSON from a curl response or browser DevTools network tab, prettify it, and read the structure clearly without needing to install a JSON viewer extension.
  • Config file normalization: Before committing a config file (appsettings.json, package.json, etc.), prettify and sort keys so PR diffs show only real changes rather than formatting noise.
  • Minification for production: Before embedding a JSON payload in source code or a test fixture, minify it to reduce size and avoid trailing whitespace issues.
  • Diff preparation: Sort keys in both versions of a JSON file before comparing them with the Diff Checker. This eliminates false positives from key reordering and surfaces only value changes.

How it works

All operations parse the JSON with JSON.parse() first, so invalid JSON produces an error message before any transformation is attempted. Prettify calls JSON.stringify(obj, null, 2). Minify calls JSON.stringify(obj) without the spacing argument. Sort Keys recursively walks the object and rebuilds it with keys sorted using Object.keys(obj).sort() - arrays are preserved in order, only object keys are sorted.

Common mistakes

  • Trailing commas: JSON does not allow trailing commas after the last property or array element. {"a": 1,} is invalid JSON (it is valid JavaScript, which confuses many developers). The validator will catch this and report the exact parse error.
  • Single quotes instead of double quotes: JSON strings must use double quotes. {'key': 'value'} is invalid JSON. Replace single quotes with double quotes - the validator will identify this error.
  • Comments in JSON: JSON does not support comments (// or /* */). If your source file uses JSONC (JSON with Comments, used in VS Code configs), strip the comments before pasting here.

FAQ

Does sort keys affect arrays
No. Arrays are order-sensitive data structures and are not sorted. Only object keys are reordered alphabetically. Array elements remain in their original order.

What is the difference between this and the JSON Formatter
The JSON Formatter is designed for read-only inspection with path extraction, schema validation, and diff comparison. The JSON Editor is for quick inline editing and transformation. Use the editor for day-to-day cleanups, and the formatter for deeper structural analysis.

Can this validate against a JSON Schema
No. For schema validation, use the JSON Formatter which includes a JSON Schema subset validator.

Is my JSON sent anywhere
No. All operations run locally in your browser using JavaScript's built-in JSON object.

Working with JSON in practice

JSON (JavaScript Object Notation) has become the default data interchange format for web APIs, configuration files, and structured logs. Its simplicity — just objects, arrays, strings, numbers, booleans, and null — makes it readable, but also makes certain categories of mistakes easy to introduce and hard to spot without tooling.

Prettifying for readability: Minified JSON — single-line, no whitespace — is optimal for transmission but unreadable for inspection. Prettifying expands it with consistent indentation, putting each key-value pair on its own line. When debugging an API response or reviewing a config change, prettified output lets you scan the structure visually rather than counting braces. This tool uses 2-space indentation by default, which is the most common convention in JavaScript and TypeScript ecosystems.

Minifying for production: Every whitespace character in JSON is transmitted bytes. For large payloads sent frequently — analytics events, telemetry, high-frequency API calls — minification reduces payload size without changing the data. The difference between a 2KB prettified config and a 800-byte minified version matters at scale. Minification also removes any formatting inconsistencies introduced by different editors or serializers.

Sorting keys for diffs: JSON objects are formally unordered, but serializers often produce keys in insertion order. When the same JSON structure is serialized by different systems or at different times, key order can vary, producing noisy diffs. Sorting keys alphabetically before committing a config file or before comparing versions makes diffs reflect actual data changes rather than serialization order changes.

Common JSON editing mistakes

Trailing commas: JSON (unlike JavaScript) does not allow a trailing comma after the last element of an array or object. {"key": "value",} is invalid JSON. Many developers coming from JavaScript or Python (which allows trailing commas in list literals) run into this repeatedly. Paste suspect JSON here to immediately identify whether a trailing comma is causing a parse error.

Single quotes: JSON requires double quotes for strings. {'key': 'value'} is not valid JSON, even though it is valid Python dict syntax and looks reasonable. If you are copying output from a Python REPL, Django shell, or similar environment, you may get single-quoted strings that need conversion before the JSON can be parsed.

Unescaped special characters: Newlines, tabs, and certain Unicode characters inside strings must be escaped. A literal newline inside a JSON string value is invalid. The correct form is \n. If you are pasting multiline text into a JSON value, validate it here first — the parser will identify any escape issues immediately.

Numeric precision: JSON numbers are IEEE 754 doubles. Integers larger than 2⁵³ (9,007,199,254,740,992) cannot be represented exactly in JavaScript. If your API returns 64-bit integer IDs (common in distributed systems), they should be transmitted as strings in JSON, not as numbers. This editor will show the value but cannot flag precision loss — use your application's JSON library for that.

For structural analysis beyond editing, use the JSON Formatter. For YAML counterpart, see YAML Validator. To compare two JSON objects, try Diff Checker.

Related tools