JSON Pretty + Highlight
A JSON input that pretty-prints and syntax-highlights, via Prism.
Requires Bootstrap 5, Prism. Add the CDN tags below to your page (styles in
<head>, scripts before </body>). The downloaded file already includes them.<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-tomorrow.min.css"><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script><script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/prism.min.js"></script><div class="card border-0 shadow-sm" style="width:380px;max-width:100%"><div class="card-body">
<textarea class="form-control form-control-sm mb-2" id="jvIn" rows="2">{"user":"atlas","roles":["admin","editor"],"active":true}</textarea>
<button class="btn btn-primary btn-sm mb-2" id="jvBtn">Highlight</button>
<pre class="mb-0 rounded"><code class="language-json" id="jvOut"></code></pre>
</div></div>function run(){var out=document.getElementById('jvOut');try{out.textContent=JSON.stringify(JSON.parse(document.getElementById('jvIn').value),null,2);Prism.highlightElement(out)}catch(e){out.textContent='Invalid JSON'}}
document.getElementById('jvBtn').onclick=run;run();Free to use.This component uses Bootstrap 5, Prism (linked above). Copy any file, or download a ready-to-open .html page with the CDN links already included.