Repository navigation
Expand file tree
/
Copy pathjson-formatter.html
More file actions
647 lines (584 loc) Β· 34.2 KB
/
Copy pathjson-formatter.html
File metadata and controls
647 lines (584 loc) Β· 34.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
<!DOCTYPE html>
<html lang="en">
<head>
<include src="_partials/meta-base.html"></include>
<title>JSON Formatter β HTML Tools</title>
<meta name="description" content="Format, validate, and minify JSON with syntax highlighting and a collapsible tree view. Runs in your browser β no installs, no servers, no tracking.">
<link rel="canonical" href="https://tools.mazipan.space/json-formatter">
<meta property="og:title" content="JSON Formatter β HTML Tools">
<meta property="og:description" content="Format, validate, and minify JSON with syntax highlighting and a collapsible tree view. Runs in your browser β no installs, no servers, no tracking.">
<meta property="og:url" content="https://tools.mazipan.space/json-formatter">
<meta name="twitter:title" content="JSON Formatter β HTML Tools">
<meta name="twitter:description" content="Format, validate, and minify JSON with syntax highlighting and a collapsible tree view. Runs in your browser β no installs, no servers, no tracking.">
<include src="_partials/meta-social.html"></include>
<link rel="icon" type="image/png" sizes="32x32" href="favicon-json-formatter.png">
<include src="_partials/head-fonts.html"></include>
<link rel="stylesheet" href="styles.css">
<style>
mark.sh { background: #92400e; color: #fef3c7; border-radius: 2px; padding: 0 1px; }
mark.sh.sh-active { background: #f59e0b; color: #000; border-radius: 2px; padding: 0 1px; }
#search-input:-webkit-autofill,
#search-input:autofill {
-webkit-box-shadow: 0 0 0 1000px #111827 inset;
box-shadow: 0 0 0 1000px #111827 inset;
-webkit-text-fill-color: #e5e7eb;
caret-color: #e5e7eb;
}
</style>
<include src="_partials/head-theme.html"></include>
<!-- BEGIN:json-ld generated by scripts/generate-sections.mjs β re-run after editing tools.json -->
<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebApplication","name":"JSON Formatter","url":"https://tools.mazipan.space/json-formatter","description":"Format, validate, and minify JSON with syntax highlighting and a collapsible tree view. Runs in your browser β no installs, no servers, no tracking.","applicationCategory":"DeveloperApplication","operatingSystem":"Any","browserRequirements":"Requires JavaScript","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},"isPartOf":{"@type":"WebSite","name":"HTML Tools","url":"https://tools.mazipan.space/"}}</script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"HTML Tools","item":"https://tools.mazipan.space/"},{"@type":"ListItem","position":2,"name":"JSON Formatter","item":"https://tools.mazipan.space/json-formatter"}]}</script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"FAQPage","mainEntity":[{"@type":"Question","name":"Is JSON Formatter free?","acceptedAnswer":{"@type":"Answer","text":"Yes. Every tool here runs entirely in your browser β no accounts, no quotas, no rate limits."}},{"@type":"Question","name":"Does my JSON ever leave my computer?","acceptedAnswer":{"@type":"Answer","text":"No. The page is a single static HTML file; all parsing and formatting happen locally in your browser."}},{"@type":"Question","name":"What's the difference between Format and Minify?","acceptedAnswer":{"@type":"Answer","text":"Format pretty-prints with two-space indentation for readability. Minify strips whitespace and newlines so the output is the smallest valid JSON."}},{"@type":"Question","name":"Can I search through formatted output?","acceptedAnswer":{"@type":"Answer","text":"Yes. Press Ctrl/Cmd+F to open an inline search that highlights matches across keys and values, even inside the collapsible tree view."}}]}</script>
<!-- END:json-ld -->
</head>
<body class="bg-gray-950 text-gray-200 min-h-screen flex flex-col">
<include src="_partials/icons.html"></include>
<!-- Site header -->
<header class="border-b border-gray-800 px-6 py-4">
<nav aria-label="Breadcrumb" class="max-w-[1100px] mx-auto flex items-center gap-3">
<a href="index.html" class="no-underline text-white font-bold text-lg tracking-tight hover:text-blue-400 transition-colors">
HTML Tools
</a>
<span class="text-gray-700">/</span>
<span class="text-gray-400 text-sm flex items-center gap-1.5" aria-current="page">
ποΈ JSON Formatter
</span>
</nav>
</header>
<main class="max-w-[1100px] mx-auto w-full flex-1 py-8 px-6">
<header class="mb-7">
<h1 class="text-3xl font-bold text-white flex items-center gap-3">ποΈ JSON Formatter</h1>
<p class="mt-1.5 text-sm text-gray-500">Prettify, minify, and validate JSON instantly in your browser.</p>
</header>
<!-- Toolbar -->
<div class="flex flex-wrap gap-2 items-center mb-4">
<button onclick="format()" class="btn btn-primary">β¨ Prettify</button>
<button onclick="minify()" class="btn btn-secondary">ποΈ Minify</button>
<button onclick="clearAll()" class="btn btn-danger">ποΈ Clear</button>
</div>
<!-- Panels -->
<div class="grid grid-cols-2 gap-4 max-md:grid-cols-1">
<div>
<div class="flex items-center justify-between mb-2">
<label class="text-xs font-semibold text-gray-500 uppercase tracking-wide">Input</label>
</div>
<textarea id="input"
placeholder="Paste JSON here..."
spellcheck="false"
oninput="onInput()"
class="w-full h-[500px] min-h-[500px] rounded-lg border border-gray-700 bg-gray-900
text-gray-200 font-mono text-[0.8rem] leading-relaxed p-4 resize-y outline-none
focus:border-blue-400 transition-colors"></textarea>
</div>
<div>
<div class="flex items-center justify-between mb-2">
<label class="text-xs font-semibold text-gray-500 uppercase tracking-wide">Output</label>
<div class="flex gap-1 items-center">
<button onclick="copyOutput()" class="btn btn-secondary btn-sm">π Copy</button>
<span class="w-px h-3 bg-gray-700 mx-0.5"></span>
<button id="btn-tree" onclick="setView('tree')" class="btn btn-sm btn-active">π³ Tree</button>
<button id="btn-raw" onclick="setView('raw')" class="btn btn-secondary btn-sm">π Raw</button>
<span class="w-px h-3 bg-gray-700 mx-0.5"></span>
<button onclick="openSearch()" title="Search (Ctrl+F / βF)" class="btn btn-secondary btn-sm">π Search</button>
</div>
</div>
<!-- Search bar -->
<div id="search-bar" style="display:none"
class="flex items-center gap-1.5 mb-2 px-2 py-1.5 rounded-lg border border-gray-700 bg-gray-900/70">
<input id="search-input" type="text" placeholder="Search keys & valuesβ¦" spellcheck="false" autocomplete="off"
oninput="runSearch()"
onkeydown="onSearchKey(event)"
class="flex-1 bg-transparent text-gray-200 font-mono text-[0.78rem] outline-none placeholder-gray-600 min-w-0">
<span id="search-count" class="text-[0.7rem] text-gray-500 whitespace-nowrap select-none"></span>
<button onclick="navigateSearch(-1)" title="Previous (Shift+Enter)" class="btn-icon btn-icon-sm ghost"><svg class="icon" aria-hidden="true"><use href="#icon-arrow-up"/></svg></button>
<button onclick="navigateSearch(1)" title="Next (Enter)" class="btn-icon btn-icon-sm ghost"><svg class="icon" aria-hidden="true"><use href="#icon-arrow-down"/></svg></button>
<button onclick="closeSearch()" title="Close (Esc)"
class="btn btn-danger btn-sm
bg-gray-800 border-gray-600 text-gray-400 hover:border-red-400 hover:text-red-400">β</button>
</div>
<div id="output"
class="w-full h-[500px] min-h-[500px] rounded-lg border border-gray-700 bg-gray-900
font-mono text-[0.8rem] leading-relaxed p-4 overflow-auto resize-y"></div>
</div>
</div>
<div id="status" class="mt-2.5 text-xs text-gray-500 min-h-[18px]"></div>
</main>
<script src="json-utils.js"></script>
<script>
const inputEl = document.getElementById('input');
const outputEl = document.getElementById('output');
const statusEl = document.getElementById('status');
let currentView = 'tree';
let lastParsed = null;
let lastFormatted = '';
// ββ View toggle ββββββββββββββββββββββββββββββββββββββββββββββ
function setView(v) {
currentView = v;
const treeBtn = document.getElementById('btn-tree');
const rawBtn = document.getElementById('btn-raw');
treeBtn.classList.toggle('btn-active', v === 'tree');
treeBtn.classList.toggle('btn-secondary', v !== 'tree');
rawBtn.classList.toggle('btn-active', v === 'raw');
rawBtn.classList.toggle('btn-secondary', v !== 'raw');
renderOutput();
}
function renderOutput() {
if (!lastParsed && lastFormatted === '') { outputEl.innerHTML = ''; return; }
if (currentView === 'tree' && lastParsed !== null) {
outputEl.className = outputEl.className.replace('whitespace-pre', '');
outputEl.innerHTML = '';
const root = document.createElement('div');
root.className = 'tree-root';
const counter = { n: 1 };
root.appendChild(buildTree(lastParsed, null, true, counter));
outputEl.appendChild(root);
} else {
if (!outputEl.className.includes('whitespace-pre')) {
outputEl.className += ' whitespace-pre';
}
outputEl.innerHTML = highlightRaw(lastFormatted);
}
const bar = document.getElementById('search-bar');
if (bar && bar.style.display !== 'none') runSearch();
}
// ββ Format / Minify ββββββββββββββββββββββββββββββββββββββββββ
function format() {
const raw = inputEl.value.trim();
if (!raw) { lastParsed = null; lastFormatted = ''; renderOutput(); setStatus(''); return; }
try {
const { value, fixed } = tolerantParse(raw);
lastParsed = value;
lastFormatted = JSON.stringify(value, null, 2);
outputEl.classList.remove('border-red-500');
outputEl.classList.add('border-gray-700');
renderOutput();
const suffix = fixed ? ' Β· auto-fixed' : '';
setStatus(`Valid JSON Β· ${countKeys(lastParsed)} keys${suffix}`, 'ok');
} catch (e) {
lastParsed = null; lastFormatted = '';
outputEl.classList.remove('border-gray-700');
outputEl.classList.add('border-red-500');
outputEl.className += ' whitespace-pre-wrap';
outputEl.textContent = e.message;
setStatus(e.message, 'err');
}
}
function minify() {
const raw = inputEl.value.trim();
if (!raw) return;
try {
const { value, fixed } = tolerantParse(raw);
lastParsed = value;
lastFormatted = JSON.stringify(value);
setView('raw');
setStatus(fixed ? 'Minified Β· auto-fixed' : 'Minified', 'ok');
} catch (e) {
outputEl.textContent = e.message;
setStatus(e.message, 'err');
}
}
// ββ Tree builder βββββββββββββββββββββββββββββββββββββββββββββ
function buildTree(value, key, isLast, counter) {
const node = document.createElement('div');
node.className = 'tree-node';
if (value === null || typeof value !== 'object') {
const row = document.createElement('div');
row.className = 'tree-row';
row.innerHTML =
`<span class="line-num">${counter.n++}</span>` +
'<span class="toggle-btn leaf">βΆ</span>' +
(key !== null ? `<span class="json-key">"${escHtml(key)}"</span><span class="json-punct">: </span>` : '') +
primitiveHtml(value) +
(isLast ? '' : '<span class="tree-comma">,</span>');
node.appendChild(row);
return node;
}
const isArray = Array.isArray(value);
const keys = isArray ? value.map((_, i) => i) : Object.keys(value);
const openB = isArray ? '[' : '{';
const closeB = isArray ? ']' : '}';
const previewLabel = isArray
? `${keys.length} item${keys.length !== 1 ? 's' : ''}`
: `${keys.length} key${keys.length !== 1 ? 's' : ''}`;
const headerRow = document.createElement('div');
headerRow.className = 'tree-row';
headerRow.style.cursor = 'pointer';
const toggleBtn = document.createElement('span');
toggleBtn.className = 'toggle-btn';
toggleBtn.textContent = 'βΌ';
const keyHtml = key !== null
? `<span class="json-key">"${escHtml(String(key))}"</span><span class="json-punct">: </span>`
: '';
headerRow.innerHTML =
`<span class="line-num">${counter.n++}</span>` +
keyHtml +
`<span class="json-punct">${openB}</span>` +
`<span class="collapsed-preview" style="display:none"> ${previewLabel} </span>`;
headerRow.insertBefore(toggleBtn, headerRow.children[1]);
node.appendChild(headerRow);
const childrenEl = document.createElement('div');
childrenEl.className = 'tree-children';
keys.forEach((k, i) => {
childrenEl.appendChild(buildTree(isArray ? value[k] : value[k], isArray ? null : k, i === keys.length - 1, counter));
});
node.appendChild(childrenEl);
const footerRow = document.createElement('div');
footerRow.className = 'tree-row';
footerRow.innerHTML =
`<span class="line-num">${counter.n++}</span>` +
'<span class="toggle-btn leaf">βΆ</span>' +
`<span class="json-punct">${closeB}</span>` +
(isLast ? '' : '<span class="tree-comma">,</span>');
node.appendChild(footerRow);
const collapsedPreview = headerRow.querySelector('.collapsed-preview');
let collapsed = false;
toggleBtn.addEventListener('click', (e) => {
e.stopPropagation();
collapsed = !collapsed;
toggleBtn.textContent = collapsed ? 'βΆ' : 'βΌ';
childrenEl.style.display = collapsed ? 'none' : '';
footerRow.style.display = collapsed ? 'none' : '';
collapsedPreview.style.display = collapsed ? 'inline' : 'none';
if (collapsed) {
collapsedPreview.textContent = ` ${previewLabel} ${closeB}${isLast ? '' : ','}`;
}
});
headerRow.addEventListener('click', () => toggleBtn.click());
return node;
}
// ββ Raw syntax highlight βββββββββββββββββββββββββββββββββββββ
function highlightRaw(json) {
const highlighted = escHtml(json).replace(
/("(?:\\u[0-9a-fA-F]{4}|\\[^u]|[^\\"])*"(\s*:)?)|(\b(?:true|false|null)\b)|(-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,
(m) => {
if (m.endsWith(':')) return `<span class="json-key">${m}</span>`;
if (m.startsWith('"')) return `<span class="json-string">${m}</span>`;
if (m === 'true' || m === 'false') return `<span class="json-bool">${m}</span>`;
if (m === 'null') return `<span class="json-null">${m}</span>`;
return `<span class="json-number">${m}</span>`;
}
);
const lines = highlighted.split('\n');
const pad = String(lines.length).length;
return lines.map((line, i) =>
`<span class="line-num">${String(i + 1).padStart(pad)}</span>${line}`
).join('\n');
}
// ββ Helpers ββββββββββββββββββββββββββββββββββββββββββββββββββ
function primitiveHtml(v) {
if (v === null) return `<span class="json-null">null</span>`;
if (typeof v === 'boolean') return `<span class="json-bool">${v}</span>`;
if (typeof v === 'number') return `<span class="json-number">${v}</span>`;
return `<span class="json-string">"${escHtml(v)}"</span>`;
}
function escHtml(s) {
return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
}
function countKeys(obj, d = 0) {
if (d > 5 || typeof obj !== 'object' || obj === null) return 0;
const keys = Object.keys(obj);
return keys.length + keys.reduce((s, k) => s + countKeys(obj[k], d + 1), 0);
}
function setStatus(msg, type = '') {
statusEl.textContent = msg;
statusEl.className = type === 'ok'
? 'mt-2.5 text-xs min-h-[18px] text-green-400'
: type === 'err'
? 'mt-2.5 text-xs min-h-[18px] text-red-400'
: 'mt-2.5 text-xs min-h-[18px] text-gray-500';
}
function copyOutput() {
if (!lastFormatted) return;
navigator.clipboard.writeText(lastFormatted).then(() => {
setStatus('Copied to clipboard!', 'ok');
setTimeout(() => setStatus(''), 2000);
});
}
function clearAll() {
inputEl.value = '';
lastParsed = null;
lastFormatted = '';
outputEl.innerHTML = '';
outputEl.classList.remove('border-red-500', 'whitespace-pre', 'whitespace-pre-wrap');
outputEl.classList.add('border-gray-700');
setStatus('');
closeSearch();
}
let debounceTimer;
function onInput() {
clearTimeout(debounceTimer);
debounceTimer = setTimeout(format, 300);
}
// ββ Search βββββββββββββββββββββββββββββββββββββββββββββββββββ
let searchMatches = [];
let searchCurrent = -1;
function openSearch() {
const bar = document.getElementById('search-bar');
bar.style.display = 'flex';
document.getElementById('search-input').select();
document.getElementById('search-input').focus();
}
function closeSearch() {
const bar = document.getElementById('search-bar');
if (!bar) return;
bar.style.display = 'none';
clearSearchHighlights();
searchMatches = [];
searchCurrent = -1;
document.getElementById('search-count').textContent = '';
}
function clearSearchHighlights() {
outputEl.querySelectorAll('mark.sh').forEach(mark => {
const parent = mark.parentNode;
if (parent) {
parent.replaceChild(document.createTextNode(mark.textContent), mark);
parent.normalize();
}
});
}
function runSearch() {
clearSearchHighlights();
searchMatches = [];
searchCurrent = -1;
const query = document.getElementById('search-input').value;
const countEl = document.getElementById('search-count');
if (!query) { countEl.textContent = ''; return; }
// In tree view, expand all collapsed nodes so all text is visible and searchable
if (currentView === 'tree') {
outputEl.querySelectorAll('.toggle-btn:not(.leaf)').forEach(btn => {
if (btn.textContent === 'βΆ') btn.click();
});
}
const lowerQuery = query.toLowerCase();
const walker = document.createTreeWalker(outputEl, NodeFilter.SHOW_TEXT, {
acceptNode(node) {
if (node.parentElement && node.parentElement.classList.contains('line-num')) {
return NodeFilter.FILTER_REJECT;
}
return NodeFilter.FILTER_ACCEPT;
}
});
const textNodes = [];
let node;
while ((node = walker.nextNode())) textNodes.push(node);
textNodes.forEach(textNode => {
const text = textNode.textContent;
const lowerText = text.toLowerCase();
let idx = lowerText.indexOf(lowerQuery);
if (idx === -1) return;
const frag = document.createDocumentFragment();
let lastIdx = 0;
while (idx !== -1) {
if (idx > lastIdx) frag.appendChild(document.createTextNode(text.slice(lastIdx, idx)));
const mark = document.createElement('mark');
mark.className = 'sh';
mark.textContent = text.slice(idx, idx + query.length);
frag.appendChild(mark);
searchMatches.push(mark);
lastIdx = idx + query.length;
idx = lowerText.indexOf(lowerQuery, lastIdx);
}
if (lastIdx < text.length) frag.appendChild(document.createTextNode(text.slice(lastIdx)));
textNode.parentNode.replaceChild(frag, textNode);
});
if (searchMatches.length === 0) {
countEl.textContent = 'No matches';
countEl.className = 'text-[0.7rem] text-red-400 whitespace-nowrap select-none';
return;
}
countEl.className = 'text-[0.7rem] text-gray-500 whitespace-nowrap select-none';
searchCurrent = 0;
updateSearchActive();
}
function updateSearchActive() {
searchMatches.forEach((m, i) => {
m.className = i === searchCurrent ? 'sh sh-active' : 'sh';
});
const active = searchMatches[searchCurrent];
if (active) active.scrollIntoView({ block: 'center', behavior: 'smooth' });
document.getElementById('search-count').textContent =
`${searchCurrent + 1} / ${searchMatches.length}`;
}
function navigateSearch(dir) {
if (searchMatches.length === 0) return;
searchCurrent = (searchCurrent + dir + searchMatches.length) % searchMatches.length;
updateSearchActive();
}
function onSearchKey(e) {
if (e.key === 'Enter') {
e.preventDefault();
navigateSearch(e.shiftKey ? -1 : 1);
} else if (e.key === 'Escape') {
closeSearch();
}
}
document.addEventListener('keydown', (e) => {
if ((e.ctrlKey || e.metaKey) && e.key === 'f') {
e.preventDefault();
openSearch();
}
});
inputEl.focus();
</script>
<section class="max-w-[1100px] mx-auto w-full px-6 py-8 border-t border-gray-800">
<div class="grid gap-6 md:grid-cols-2">
<div>
<h2 class="text-xl font-bold text-white mb-4">About JSON Formatter</h2>
<p class="text-gray-400 leading-relaxed">Paste JSON to get a properly indented, syntax-highlighted version. Switch between formatted and minified output, search through the result, and explore deeply nested structures with the collapsible tree view.</p>
</div>
<div>
<h2 class="text-xl font-bold text-white mb-4">How to use</h2>
<ol class="text-gray-400 leading-relaxed space-y-2 list-decimal list-inside">
<li>Paste JSON into the input panel.</li>
<li>Choose <strong class="text-gray-300">Format</strong> for pretty-printed output or <strong class="text-gray-300">Minify</strong> for a single line.</li>
<li>Browse the tree, collapse branches, or search for a specific key.</li>
<li>Click the copy button to copy the output to your clipboard.</li>
</ol>
</div>
<div>
<h2 class="text-xl font-bold text-white mb-4">Common use cases</h2>
<ul class="text-gray-400 leading-relaxed space-y-2 list-disc list-inside">
<li>Reading API responses copied from the browser network tab or <code class="text-gray-300">curl</code>.</li>
<li>Cleaning up JSON pasted from logs or chat windows.</li>
<li>Quickly checking that a config file is valid JSON.</li>
<li>Inspecting deeply nested data without scrolling through a wall of braces.</li>
</ul>
</div>
<div>
<h2 class="text-xl font-bold text-white mb-4">Tips</h2>
<ul class="text-gray-400 leading-relaxed space-y-2 list-disc list-inside">
<li>Validation errors show the line and column so you can fix them in place.</li>
<li>Output is always strict JSON, safe to feed straight into another parser.</li>
<li>Everything runs locally β your JSON never leaves the browser.</li>
</ul>
</div>
</div>
</section>
<!-- BEGIN:faq generated by scripts/generate-sections.mjs β re-run after editing tools.json -->
<section class="max-w-[1100px] mx-auto w-full px-6 py-8 border-t border-gray-800">
<h2 class="text-xl font-bold text-white mb-6">FAQ</h2>
<div class="space-y-2">
<details class="disclosure">
<summary>Is JSON Formatter free?</summary>
<div class="disclosure-content"><div class="disclosure-body">Yes. Every tool here runs entirely in your browser β no accounts, no quotas, no rate limits.</div></div>
</details>
<details class="disclosure">
<summary>Does my JSON ever leave my computer?</summary>
<div class="disclosure-content"><div class="disclosure-body">No. The page is a single static HTML file; all parsing and formatting happen locally in your browser.</div></div>
</details>
<details class="disclosure">
<summary>What's the difference between Format and Minify?</summary>
<div class="disclosure-content"><div class="disclosure-body">Format pretty-prints with two-space indentation for readability. Minify strips whitespace and newlines so the output is the smallest valid JSON.</div></div>
</details>
<details class="disclosure">
<summary>Can I search through formatted output?</summary>
<div class="disclosure-content"><div class="disclosure-body">Yes. Press Ctrl/Cmd+F to open an inline search that highlights matches across keys and values, even inside the collapsible tree view.</div></div>
</details>
</div>
</section>
<!-- END:faq -->
<!-- BEGIN:more-tools generated by scripts/generate-sections.mjs β re-run after editing tools.json -->
<section class="max-w-[1100px] mx-auto w-full px-6 py-8 border-t border-gray-800">
<h2 class="text-xl font-bold text-white mb-6">More tools</h2>
<div class="space-y-4">
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">JSON</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/json-to-ts" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π· JSON to TypeScript</a>
<a href="/json-diff" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π JSON Diff</a>
<a href="/json-sort" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π€ JSON Sort</a>
<a href="/csv-to-json" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π JSON β CSV</a>
<a href="/json-to-yaml" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π JSON β YAML</a>
<a href="/json-to-schema" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π‘οΈ JSON to Validator Schema</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">Code</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/regex-tester" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π§ͺ Regex Tester</a>
<a href="/svg-to-jsx" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">βοΈ SVG to JSX</a>
<a href="/svg-rasterizer" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π· SVG to Raster</a>
<a href="/cron-decoder" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">β±οΈ Cron Decoder</a>
<a href="/snippet-to-image" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">πΈ Code Snippet to Image</a>
<a href="/text-diff" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π Text Diff</a>
<a href="/markdown-preview" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π Markdown Preview</a>
<a href="/semver-checker" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π·οΈ SemVer Checker</a>
<a href="/jwt-decoder" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π JWT Decoder</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">Ornaments</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/gradients" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π¨ Gradients</a>
<a href="/blob" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π«§ Blob Generator</a>
<a href="/waves" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">γ°οΈ Wave Generator</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">Image</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/image-compressor" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">ποΈ Image Compressor</a>
<a href="/image-resizer" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π Image Resizer</a>
<a href="/image-cropper" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">βοΈ Image Cropper</a>
<a href="/image-converter" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">πΌοΈ Image Format Converter</a>
<a href="/image-watermark" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π Image Watermark</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">Audio</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/mp3-tag-editor" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π΅ MP3 Tag Editor</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">Web / SEO</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/meta-tag-preview" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π Meta Tag Preview</a>
<a href="/user-agent-parser" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π΅οΈ User Agent Parser</a>
<a href="/og-image-builder" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">πΌοΈ OG Image Builder</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">Generators</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/qr-code-generator" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π± QR Code Generator</a>
<a href="/lorem-ipsum" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π Lorem Ipsum Generator</a>
<a href="/avatar-generator" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π€ Avatar Generator</a>
<a href="/favicon-generator" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">β Favicon Generator</a>
<a href="/uuid-generator" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">πͺͺ UUID Generator</a>
<a href="/wheel-of-names" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π‘ Wheel of Names</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">PDF</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/pdf-merger" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π PDF Merger</a>
<a href="/image-to-pdf" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π Image to PDF</a>
<a href="/pdf-compressor" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π€ PDF Compressor</a>
<a href="/pdf-splitter" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">βοΈ PDF Splitter</a>
<a href="/pdf-page-manager" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">ποΈ PDF Page Manager</a>
<a href="/pdf-watermark" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π§ PDF Watermark</a>
<a href="/pdf-signature" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">βοΈ PDF Signature</a>
<a href="/pdf-to-image" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">πΌοΈ PDF to Image</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">Time</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/pomodoro-timer" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π
Pomodoro Timer</a>
</div>
</div>
</div>
</section>
<!-- END:more-tools -->
<footer class="max-w-[1100px] mx-auto w-full py-8 px-6 border-t border-gray-800 text-center text-sm text-gray-600">
<div>© <span id="year"></span> <a href="https://mazipan.space" rel="noreferrer noopener" target="_blank" class="text-blue-400 transition-colors">Irfan Maulana</a> & Claude</div>
<div><span id="deploy-time"></span></div>
<div><span id="commit-sha"></span><a href="https://github.com/mazipan/html-tools" rel="noreferrer noopener" target="_blank" class="text-blue-400 transition-colors">Source</a></div>
<div><a href="design-system.html" rel="nofollow" class="text-blue-400 transition-colors">Design system</a></div>
<div><a href="https://baca-quran.id" rel="noreferrer noopener" target="_blank" class="text-blue-400 transition-colors">Baca Quran</a> Β· <a href="https://games.mazipan.space" rel="noreferrer noopener" target="_blank" class="text-blue-400 transition-colors">Games</a></div>
</footer>
<include src="_partials/footer-script.html"></include>
</body>
</html>