JSON Formatter Tool
An interactive JSON editor: type or paste JSON into the textarea and a status badge tells you immediately whether it parses, with the parser's own error message shown below when it doesn't. Format pretty-prints the current text with 2-space indentation, Minify collapses it to a single line, and both simply leave the text untouched if it isn't valid JSON to begin with.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button, badge dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/json-formatter-tool.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/devtools/devtools26.tsx instead.
Usage
The file also exports devtools26Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Devtools26, devtools26Demo } from "@/components/blocks/devtools/devtools26"; export default function Page() { return <Devtools26 {...devtools26Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "JSON Formatter" | Section heading. |
| description | string | "Paste in JSON, then format or minify it. Validity updates as you type." | Section intro text below the heading. |
| initialValue | string | none | Seed text for the editor. The component copies this into its own local state on mount and owns all edits from there; changing this prop later does not reset an already-mounted editor. |
| className | string | none | Extra classes for the outer section element. |
Behavior notes
- Validation is real: on every keystroke the current textarea value is run through JSON.parse in a try/catch, computed inline during render (not stored in its own state and not derived in an effect). The Valid/Invalid badge and the error text both come straight from that try/catch, so the message shown is whatever the JS engine's own parser reports, not a custom validator.
- Format runs JSON.stringify(JSON.parse(text), null, 2); Minify runs JSON.stringify(JSON.parse(text)). Both are wrapped in try/catch: if the current text fails to parse, the button click is a silent no-op and the text is left exactly as the user typed it, so they can see and fix the syntax error instead of having it discarded.
- Copy uses navigator.clipboard.writeText on the current textarea contents (not the initialValue), so it copies whatever state the editor is currently in, formatted, minified, or hand-edited.
- This block requires a browser clipboard API and local component state, so it is a "use client" component; initialValue is supplied once by the caller as the seed and is not re-synced afterward.
More DevTools Blocks
View all →api-endpoints-sample-call
API Endpoints With Sample Call
Reference list of API endpoints paired with a live sample request and response panel.
cicd-pipeline-status
CI/CD Pipeline Status
Recent CI/CD pipeline runs with per-stage status chips and overall run badges.
code-diff-viewer
Code Diff Viewer
Unified code diff panel with a file header change summary and colored addition/deletion lines.
keyboard-shortcuts-reference
Keyboard Shortcuts Reference
Grouped keyboard shortcut reference with keycap-styled key combos.
performance-waterfall
Performance Waterfall
Network request waterfall chart with cascading timing bars colored by duration.
service-health-board
Service Health Board
Infrastructure status board with a live summary strip and per-service uptime, latency, and health.