fundamentals

How to Edit a JSON File: Step-by-Step Guide for Every Platform

Learn how to edit JSON files on Windows, macOS, Linux, and online. Step-by-step instructions for beginners and developers with tips on validation, formatting, and avoiding common mistakes.

JSON Console Team
Updated on: March 17, 2026
10 min read
Developer editing a JSON file in a code editor with syntax highlighting

Editing a JSON file might seem straightforward, but one misplaced comma or missing bracket can break an entire application. Whether you're modifying a configuration file, updating API responses, or cleaning up data, knowing how to edit JSON files correctly saves hours of debugging.

This guide walks you through every method for editing JSON files — from quick online editors to command-line tools — with practical examples and common pitfalls to avoid.

Table of Contents

1. What Is a JSON File?

2. How to Edit a JSON File Online

3. Edit JSON Files on Windows

4. Edit JSON Files on macOS

5. Edit JSON Files on Linux

6. Edit JSON from the Command Line

7. Common Edits: Update, Rename, Delete

8. Editing a config.json File

9. Editing JSON in Games and Apps (Minecraft and Others)

10. Common JSON Editing Mistakes

11. JSON Editing Best Practices

12. FAQ

What Is a JSON File?

JSON (JavaScript Object Notation) is a lightweight data format used everywhere in modern software — from API responses and configuration files to database exports and package manifests. A JSON file uses the .json extension and contains structured data as key-value pairs, arrays, strings, numbers, booleans, and null values.

Here's a simple example:

{
  "name": "My Application",
  "version": "2.1.0",
  "settings": {
    "theme": "dark",
    "language": "en",
    "notifications": true
  },
  "dependencies": ["react", "next", "tailwind"]
}

Because JSON has strict syntax rules (no trailing commas, double quotes required for keys and strings, no comments), editing it by hand in a plain text editor is error-prone. That's why purpose-built JSON editors exist.

How to Edit a JSON File Online

The fastest way to edit a JSON file is with an online JSON editor — no installation required. Here's how to do it with JSON Console:

Step 1: Open the Editor

Navigate to JSON Console's JSON Editor. The editor loads instantly in your browser with no sign-up required.

Step 2: Load Your JSON File

You have three options:

- Paste directly: Copy your JSON content and paste it into the editor

- Upload a file: Click the upload button to load a .json file from your computer

- Type from scratch: Start typing JSON directly in the code editor

Step 3: Edit Your Data

The editor provides multiple ways to work with your JSON:

- Code View: Edit raw JSON with syntax highlighting, auto-completion, and real-time error detection powered by the Monaco editor (the same engine behind VS Code)

- Tree View: Navigate and edit your JSON visually through an interactive tree structure — perfect for deeply nested objects

- Table View: View and edit array data in a spreadsheet-like format

Step 4: Validate and Export

As you edit, the editor validates your JSON in real-time, highlighting errors with precise line numbers. Once you're done:

- Click the download button to save your edited file

- Copy the formatted JSON to your clipboard

- Use the format button to auto-indent and beautify your changes

All processing happens locally in your browser, so your data never leaves your device.

Edit JSON Files on Windows

Open any browser and navigate to jsonconsole.com/json-editor. This gives you a full-featured JSON editor without installing anything — ideal if you need to make quick edits or don't want to clutter your system with additional software.

Using Visual Studio Code

1. Install VS Code if you haven't already

2. Open your JSON file: File > Open File or drag the file into VS Code

3. VS Code provides syntax highlighting and basic validation out of the box

4. Install the "Prettier" extension for auto-formatting on save

5. Save with Ctrl+S

Using Notepad++

1. Open Notepad++ and load your JSON file

2. Go to Language > JSON to enable syntax highlighting

3. Install the "JSON Viewer" plugin via Plugins > Plugin Admin for tree view

4. Edit your file and save

Using Windows Notepad

While Notepad can technically open JSON files, it lacks syntax highlighting, validation, and formatting. Use it only as a last resort for tiny edits. Right-click the .json file > Open with > Notepad.

Edit JSON Files on macOS

Open Safari, Chrome, or Firefox and go to jsonconsole.com/json-editor. Works identically to the Windows experience with full feature parity.

Using Visual Studio Code

1. Install VS Code from the official website or via Homebrew: brew install --cask visual-studio-code

2. Open your file with Cmd+O or drag it into VS Code

3. Edit with built-in JSON support and save with Cmd+S

Using TextEdit

TextEdit defaults to rich text mode, which corrupts JSON files. If you must use it:

1. Open TextEdit > Preferences > Plain Text mode

2. Open your JSON file

3. Make edits and save

A better native option is to use the built-in nano or vim in Terminal.

Edit JSON Files on Linux

Open your preferred browser and navigate to jsonconsole.com/json-editor. Particularly useful on Linux distributions where installing GUI applications can be cumbersome.

Using the Terminal with nano

nano config.json

Use arrow keys to navigate, make your edits, then press Ctrl+O to save and Ctrl+X to exit. Simple but no validation.

Using vim

vim config.json

Press i to enter insert mode, make edits, then press Esc followed by :wq to save and quit. Add JSON syntax highlighting with :set syntax=json.

Using VS Code

sudo apt install code   # Debian/Ubuntu
sudo dnf install code   # Fedora
code config.json

Edit JSON from the Command Line

For scripting and automation, command-line tools let you edit JSON files programmatically.

Using jq

jq is the Swiss Army knife for JSON processing:

# Update a value
jq '.settings.theme = "light"' config.json > tmp.json && mv tmp.json config.json

# Add a new field
jq '.settings.newField = "value"' config.json > tmp.json && mv tmp.json config.json

# Delete a field
jq 'del(.settings.oldField)' config.json > tmp.json && mv tmp.json config.json

Using Python

import json

with open('config.json', 'r') as f:
    data = json.load(f)

data['settings']['theme'] = 'light'

with open('config.json', 'w') as f:
    json.dump(data, f, indent=2)

Using Node.js

const fs = require('fs');
const data = JSON.parse(fs.readFileSync('config.json', 'utf8'));
data.settings.theme = 'light';
fs.writeFileSync('config.json', JSON.stringify(data, null, 2));

Common Edits: Update, Rename, Delete

Most edits are one of a handful of operations. Here is each one in jq and in JavaScript, starting from this file:

{
  "name": "my-app",
  "port": "8080",
  "features": ["auth"],
  "legacyFlag": true
}

Update a value

jq '.name = "my-api"' config.json > tmp.json && mv tmp.json config.json
data.name = "my-api";

Rename a key

JSON has no rename operation: copy the value to the new key, then delete the old one.

jq '.httpPort = .port | del(.port)' config.json > tmp.json && mv tmp.json config.json
data.httpPort = data.port;
delete data.port;

Delete a key

jq 'del(.legacyFlag)' config.json > tmp.json && mv tmp.json config.json
delete data.legacyFlag;

Change a value's data type

A common bug is a number stored as a string ("8080" instead of 8080). In a text editor, remove the quotes around the value. Programmatically:

jq '.port |= tonumber' config.json > tmp.json && mv tmp.json config.json
data.port = Number(data.port);

Add an item to an array

jq '.features += ["billing"]' config.json > tmp.json && mv tmp.json config.json
data.features.push("billing");

In the browser you can do the same edits on a file without any tooling: read it with await file.text(), JSON.parse it, change the object, and save it with JSON.stringify(data, null, 2). The JSON.stringify guide covers the formatting options.

Editing JSON as a spreadsheet

If the file is an array of flat records (users, products, rows exported from an API), it can be easier to edit as a table: convert it with JSON to Excel, edit the cells, and convert back with Excel to JSON. Deeply nested files don't survive this round trip well, so edit those as JSON.

Editing a config.json File

Configuration files are where a small JSON mistake does the most damage, because the application that reads the file often fails at startup with an unhelpful message.

1. Back up the file first. Copy config.json to config.json.bak before touching it.

2. Keep each value's type. If a setting was true, write false, not "false". A quoted "false" is a non-empty string, which many programs treat as true.

3. Check whether comments are allowed. Plain config.json and package.json must be strict JSON. Some files are JSONC (JSON with Comments) and accept // comments: VS Code's settings.json and TypeScript's tsconfig.json are the best-known examples.

4. Validate before you save. Paste the result into the JSON editor, which flags syntax errors as you type, or run jq . config.json, which prints an error and exits non-zero if the file is invalid.

5. Restart the application. Most programs read their config only at startup.

If the app still refuses to start, the error message usually names a position. Our JSON error guides explain the common ones, such as unexpected token at position 0.

Editing JSON in Games and Apps (Minecraft and Others)

Many games and desktop apps store settings, mods, and save data as JSON.

Minecraft (Java Edition): data packs and resource packs are folders of JSON files: recipes, loot tables, advancements, block and item models, and the pack.mcmeta file at the root. Bedrock Edition add-ons describe themselves in a manifest.json and define entities and items in JSON too. Edit them with any plain-text editor (VS Code works well), keep the game closed while you edit, and back up your world first. A syntax error usually means the game ignores that file, and the reason only appears in the game log. Validating the file in the JSON editor before you load the world catches this.

Save files and app settings: when a game's save is plain JSON, the same rules apply: back up, edit, validate, and keep each value's type. Some games encode the save, for example as Base64, so the file looks like random text. Decode it first with Base64 to JSON, edit it, then encode it again with JSON to Base64. Save files that are compressed or encrypted can't be edited this way.

Common JSON Editing Mistakes

1. Trailing Commas

JSON does not allow trailing commas, unlike JavaScript:

// WRONG - trailing comma after "notifications"
{
  "theme": "dark",
  "notifications": true,
}

// CORRECT
{
  "theme": "dark",
  "notifications": true
}

2. Single Quotes Instead of Double Quotes

JSON requires double quotes for all strings and keys:

// WRONG
{'name': 'My App'}

// CORRECT
{"name": "My App"}

3. Unquoted Keys

Every key must be wrapped in double quotes:

// WRONG
{name: "My App"}

// CORRECT
{"name": "My App"}

4. Comments in JSON

Standard JSON does not support comments. If you need comments, consider using JSONC (JSON with Comments) supported by VS Code, or store documentation separately.

5. Encoding Issues

Always save JSON files as UTF-8 without BOM (Byte Order Mark). Many Windows text editors add BOM by default, which can cause parsing errors.

JSON Editing Best Practices

1. Always validate before saving: Use a JSON editor with real-time validation like JSON Console to catch errors instantly

2. Format consistently: Use 2 or 4 spaces for indentation — pick one and stick with it across your project

3. Back up before editing: Keep a copy of the original file, especially for production configuration files

4. Use version control: Track JSON changes with Git to maintain history and enable rollback

5. Validate against schemas: For structured JSON (APIs, configs), use JSON Schema validation to ensure data integrity

6. Minify for production: Remove whitespace from JSON files served over the network to reduce payload size, then use a JSON beautifier when you need to read them again

FAQ

What's the easiest way to edit a JSON file?

The easiest way is to use an online JSON editor like JSON Console. Just open it in your browser, paste your JSON, make changes with real-time validation and syntax highlighting, and download or copy the result. No installation or sign-up needed.

Can I edit a JSON file in Notepad?

Yes, but it's not recommended. Notepad lacks syntax highlighting, validation, and auto-formatting, making it easy to introduce errors. Use a JSON-aware editor like VS Code, Notepad++, or an online tool like JSON Console instead.

How do I edit a large JSON file?

For large JSON files (1MB+), use a tool with virtual scrolling and tree navigation. JSON Console handles large files efficiently with its Monaco editor engine. For programmatic editing of very large files, use streaming parsers like jq on the command line.

How do I edit JSON on my phone?

On mobile, open jsonconsole.com/json-editor in your phone's browser. The editor is responsive and works on both iOS and Android. For native apps, try Jayson (iOS) or JSON Viewer (Android).

Is it safe to edit JSON files online?

It depends on the tool. JSON Console processes everything locally in your browser — your data never leaves your device. Always check a tool's privacy policy before pasting sensitive data into online editors.

How do I add a new field to a JSON file?

In a JSON object, add a new key-value pair separated by a comma:

{
  "existingField": "value",
  "newField": "new value"
}

In JSON Console's tree view, you can add fields visually by clicking the add button on any node.

Edit JSON FileJSON EditorJSON TutorialBeginners GuideJSON Editing
{ }

JSON Console Team

The team building JSON Console's free JSON tools - formatter, editor, converters, and guides for working with JSON.