JSON Editor Online

Edit JSON as text or as a tree. The two panes stay in sync, the code is checked as you type, and format, sort, repair and undo are one click away. Your data stays in this browser tab.

Code
Tree
Ln 1, Col 1

How to edit JSON online

  1. Load your JSON. Paste it into the code pane, click Open file, or drop a file on the page. Your last draft is restored automatically when you come back.
  2. Edit in either pane. Type in the code pane, or click a key or value in the tree to change it in place. Each change in one pane updates the other.
  3. Watch the status bar. It shows Valid JSON with a key count, or the exact line and column of the first error. Click the error to jump to it. The bad line is also marked in red in the line numbers.
  4. Tidy and save. Format, Minify or Sort keys, then Download the file or Copy it to the clipboard.

Code mode and tree mode, side by side

Most online JSON editors make you switch between a text view and a tree view. Here both are open at once, because each is better at different jobs:

TaskEasier in the code paneEasier in the tree pane
Pasting or rewriting large blocks✓
Search and replace, multi-line edits✓ (browser find, Ctrl+F)
Changing one deeply nested value✓ open the branch and click the value
Renaming a key without breaking quotes or commas✓
Adding, duplicating or deleting items✓ the +, Copy and × buttons
Finding where a value is in the text✓ click the node, and its text is selected in the code pane

The tree follows the code pane. While the code has a syntax error, the tree shows the last valid version and is read-only, so a half-typed edit can never overwrite your text. When you edit in the tree, the code is rewritten with your current indentation. Number literals, key order and escapes are kept exactly.

Editing values in the tree

Click a value, type a new one and press Enter (Esc cancels). What you type is read as JSON first. If it is not valid JSON, it is stored as a string, so plain text needs no quotes:

You typeStored as
42, -3.5, 1e6number
"42"string "42" (quote numbers you want kept as text, such as ZIP codes or phone numbers)
true / falseboolean
nullnull
{}, [], {"a": 1}, [1, 2]object or array. Open it and use + to add members.
hello worldstring "hello world"

Click a key to rename it. The + button on an object adds a new key and puts it in edit mode. On an array it appends an item. Copy duplicates a node right after itself, and × deletes it. Every tree edit can be undone.

Toolbar reference: format, minify, sort and repair

ButtonWhat it does
FormatPretty-prints with the chosen indent (2 spaces, 4 spaces or tab). Only valid JSON is formatted. If the code is invalid you get the error position instead.
MinifyCompacts the document to one line with no insignificant whitespace, for configs, env vars and payloads.
Sort keysSorts object keys A–Z at every level. Arrays keep their order.
RepairTurns almost-JSON into valid JSON: removes comments and trailing commas, converts single and smart quotes, quotes bare keys, fixes Python True/None, closes truncated brackets. The status bar lists what was fixed.
Undo / RedoSteps through up to 200 snapshots, covering typing, toolbar actions and tree edits.
Open file / Download / CopyOpens a local file, saves the current JSON under the same file name, or copies it.
FullscreenGives both panes the whole window, which helps on laptops.

For a stand-alone formatter with more clean-up options and error excerpts, use the JSON formatter and cleaner. To read a very large file without editing it, the JSON viewer loads branches on demand.

Keyboard shortcuts

ShortcutAction
Ctrl/⌘ + EnterFormat
Ctrl/⌘ + ZUndo
Ctrl/⌘ + Shift + Z or Ctrl + YRedo
Ctrl/⌘ + SDownload the file
Tab / Shift + TabIndent / outdent the current line in the code pane (press Esc first to move focus out instead)
Enter / EscSave / cancel a tree edit

Editing JSON files safely

Edit JSON in code

Node.js

import { readFileSync, writeFileSync } from 'node:fs';
const cfg = JSON.parse(readFileSync('config.json', 'utf8'));
cfg.server.port = 8080;
delete cfg.legacy;
writeFileSync('config.json', JSON.stringify(cfg, null, 2) + '\n');

Python

import json
with open("config.json", encoding="utf-8") as f:
    cfg = json.load(f)
cfg["server"]["port"] = 8080
cfg.pop("legacy", None)
with open("config.json", "w", encoding="utf-8") as f:
    json.dump(cfg, f, indent=2, ensure_ascii=False)

jq

jq '.server.port = 8080 | del(.legacy)' config.json > tmp.json && mv tmp.json config.json
jq '.users += [{"name": "Ada"}]' users.json      # append to an array

Frequently asked questions

How do I edit a JSON file online?

Click Open file and choose the .json file, or paste its contents into the code pane. Edit the text directly or click keys and values in the tree, check that the status bar says Valid JSON, then click Download to save it with the same file name.

Can I edit JSON in a tree view?

Yes. The tree pane is fully editable: click a value to change it, click a key to rename it, and use the + button to add a key or item, Copy to duplicate a node, or × to delete it. Every change is written back to the code pane immediately.

Does the editor validate JSON as I type?

Yes. The code is parsed as you type. The status bar shows either Valid JSON with the number of keys and the depth, or the line and column of the first error with a short explanation, and the bad line is marked in the line numbers.

How do I type a string that looks like a number in the tree?

Wrap it in double quotes, for example "007" or "42". Without quotes the editor stores valid JSON literals such as 42, true or null as their JSON type, and anything else as a string.

Will I lose my work if I close the tab?

Your current JSON is autosaved to this browser's local storage and restored the next time you open the editor on the same device. Clear removes the saved draft. For anything important, use Download to keep a file.

Is the online JSON editor private?

Yes. Parsing, editing, formatting and repair all run in JavaScript in your browser. The JSON is not uploaded or logged, and the autosaved draft stays in your own browser.

Can it fix invalid JSON?

Click Repair. It removes comments and trailing commas, converts single and curly quotes to double quotes, quotes unquoted keys, replaces Python True/False/None and undefined or NaN, and closes truncated brackets, then shows what it changed.