DEV Community

HAU
HAU

Posted on

JSON Tasks Every Developer Does — And the Fastest Way to Do Each One

Task 1: Format a Minified JSON Response

The situation: You curl an API endpoint and get back one long line of JSON. You need to read it.

curl https://api.example.com/users/1
# {"id":1,"name":"Alice","email":"alice@example.com","address":{"city":"Berlin","zip":"10115"},"tags":["admin","user"],"active":true}
Enter fullscreen mode Exit fullscreen mode

The fast way:

  1. Paste into JSON Buddy
  2. Press Ctrl+Enter to format
{
  "id": 1,
  "name": "Alice",
  "email": "alice@example.com",
  "address": {
    "city": "Berlin",
    "zip": "10115"
  },
  "tags": ["admin", "user"],
  "active": true
}
Enter fullscreen mode Exit fullscreen mode

The editor also shows you the size, key count, and depth of the JSON in the header stats. Syntax errors are highlighted at the exact character position.

Reverse direction: Need to minify JSON before sending it? Ctrl+Shift+Enter.


Task 2: Write a Typed Model for an API Response

The situation: You're integrating an API and need to write a Go struct, TypeScript interface, or Python dataclass to represent the response.

The JSON has 15 fields, some nested. You could type it by hand, but you'll probably miss a field or get a type wrong.

The fast way:

  1. Paste the JSON into JSON Buddy
  2. Click Code Gen in the toolbar
  3. Select your language (Go, TypeScript, Java, Python, Rust, C#, PHP, Ruby, C, C++, Zig)
  4. Copy the output

For the user JSON above, selecting Go gives:

type Root struct {
    Id      int64    `json:"id"`
    Name    string   `json:"name"`
    Email   string   `json:"email"`
    Address Address  `json:"address"`
    Tags    []string `json:"tags"`
    Active  bool     `json:"active"`
}

type Address struct {
    City string `json:"city"`
    Zip  string `json:"zip"`
}
Enter fullscreen mode Exit fullscreen mode

Nested objects become separate structs automatically. Types are inferred from values.

More details: JSON to Struct Generator


Task 3: Convert Spreadsheet Data to JSON

The situation: A PM sends you a .xlsx file with test users. Your seed script expects JSON. You need to convert it without writing a pandas script.

The fast way:

  1. Click CSV/Excel to JSON in the toolbar
  2. Upload the .xlsx or paste copied table data from Excel/Google Sheets
  3. Copy the JSON output
name    age    city      role
Alice   30     Berlin    admin
Bob     25     Paris     user
Enter fullscreen mode Exit fullscreen mode

Converts to:

[
  { "name": "Alice", "age": 30, "city": "Berlin", "role": "admin" },
  { "name": "Bob",   "age": 25, "city": "Paris",  "role": "user" }
]
Enter fullscreen mode Exit fullscreen mode

Types are inferred: numbers stay numbers, booleans stay booleans. No manual post-processing needed.

More details: CSV to JSON Converter


Task 4: Bulk Replace Values Before Sharing

The situation: You want to share a JSON fixture with a colleague, but it has real email addresses and internal URLs that shouldn't be shared.

The fast way:

  1. Press Ctrl+F in the JSON editor
  2. Enable wildcard mode (.* button)
  3. Search *@*.com → Replace All → [redacted]
  4. Search https://internal.api.company.com → Replace All → https://api.example.com
  5. Done

The find & replace bar shows a live match counter (3/8) and highlights every match as you type.

More details: JSON Find & Replace


Task 5: Debug a JSON Syntax Error

The situation: JSON.parse() throws SyntaxError: Unexpected token } in JSON at position 847. You have no idea where character 847 is.

The fast way:

Paste the JSON into JSON Buddy. The editor jumps to the error position and shows a banner at the bottom:

Syntax Error
Unexpected token '}' at position 847
Enter fullscreen mode Exit fullscreen mode

The offending line is highlighted in red. Common causes caught immediately:

  • Trailing commas (invalid in JSON, common from copy-pasting JS objects)
  • Unquoted keys ({name: "Alice"} instead of {"name": "Alice"})
  • Single-quoted strings
  • Missing commas between fields
  • Comments (// ... or /* ... */ — not valid JSON)

The Format button (Ctrl+Enter) also applies heuristic fixes to invalid JSON where possible — useful for recovering a JS object literal as valid JSON.


Bonus: Load JSON from a URL

Need to inspect a public API response directly? Click the link icon in the toolbar, paste the URL, and the response is fetched and loaded into the editor. Useful for checking /.well-known/ files, inspecting GitHub API responses, or validating a public config endpoint.


Why One Tool for All of This?

Having these tasks in a single tool means:

  • No context-switching between five different websites
  • Consistent keyboard shortcuts (Ctrl+Enter, Ctrl+F, etc.)
  • No data leaving your browser — everything is local
  • Works offline after first load (PWA)
  • History of your last 50 JSON snippets, stored in localStorage

Summary

Task How to do it
Format JSON Paste → Ctrl+Enter
Validate & find errors Paste → see highlighted error position
Generate struct/class Paste → Code Gen → pick language → Copy
CSV/Excel → JSON CSV tab → upload or paste
Find & replace Ctrl+F → search → Replace All
Load from URL Toolbar link icon → paste URL

👉 json-formatter.net — free, no sign-up, no uploads, works offline.

Top comments (0)