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.

Evan Reid
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 JSON Editing Mistakes

8. JSON Editing Best Practices

9. 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 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
ER

Evan Reid

Expert in JSON technologies and modern web development practices.