How to edit JSON online
- 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.
- 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.
- 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.
- 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:
| Task | Easier in the code pane | Easier 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 type | Stored as |
|---|---|
42, -3.5, 1e6 | number |
"42" | string "42" (quote numbers you want kept as text, such as ZIP codes or phone numbers) |
true / false | boolean |
null | null |
{}, [], {"a": 1}, [1, 2] | object or array. Open it and use + to add members. |
hello world | string "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
| Button | What it does |
|---|---|
| Format | Pretty-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. |
| Minify | Compacts the document to one line with no insignificant whitespace, for configs, env vars and payloads. |
| Sort keys | Sorts object keys A–Z at every level. Arrays keep their order. |
| Repair | Turns 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 / Redo | Steps through up to 200 snapshots, covering typing, toolbar actions and tree edits. |
| Open file / Download / Copy | Opens a local file, saves the current JSON under the same file name, or copies it. |
| Fullscreen | Gives 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
| Shortcut | Action |
|---|---|
| Ctrl/⌘ + Enter | Format |
| Ctrl/⌘ + Z | Undo |
| Ctrl/⌘ + Shift + Z or Ctrl + Y | Redo |
| Ctrl/⌘ + S | Download the file |
| Tab / Shift + Tab | Indent / outdent the current line in the code pane (press Esc first to move focus out instead) |
| Enter / Esc | Save / cancel a tree edit |
Editing JSON files safely
- Large numbers survive. Many editors silently round 64-bit IDs like
9007199254740993because they go through JavaScript numbers. This editor keeps number text exactly as written, even when you edit other parts in the tree. - Duplicate keys are flagged. JSON technically allows them, but most parsers keep only the last value. The status bar warns you when a document has any.
- Encoding. Downloads are saved as UTF-8 without a byte-order mark, which is what RFC 8259 requires for JSON exchanged between systems.
- Your draft stays local. The current text is autosaved to this browser's local storage so a reload does not lose work. Clear removes it. It is never sent anywhere.
- Structure is not the same as correctness. Valid JSON can still be missing a required field. To check shape and types, test it against a JSON Schema in the JSON validator.
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.