Prettify a compact function
Input
function test(){if(true){console.log('ok');}} Output
function test() {
if (true) {
console.log('ok');
}
} Useful when copied JavaScript is all on one line.
Developer Tools
Review practical JavaScript Prettify examples so you can understand expected input, output, and common patterns faster.
Use this JavaScript Prettify tool to format compact or messy JavaScript into a more readable structure. It is useful for debugging copied snippets, inspecting generated code, reviewing minified-looking samples, cleaning simple scripts, and making JavaScript easier to scan before editing or sharing.
Example pages are especially useful for developer tools because they show what good input looks like, what kind of output to expect, and how the tool behaves in common scenarios.
Input
function test(){if(true){console.log('ok');}} Output
function test() {
if (true) {
console.log('ok');
}
} Useful when copied JavaScript is all on one line.
Input
const data={items:[1,2,3],ok:true}; Output
const data = {
items: [1, 2, 3],
ok: true
}; Makes short data-oriented JS snippets easier to inspect.
Fix: Use it for readability and quick cleanup, then review complex syntax manually.
Fix: Check missing brackets, quotes, or incomplete snippets before formatting.
Fix: Use JSON Formatter for strict JSON objects and arrays.
After reviewing these examples, run the live tool with your own input. If your task involves a follow-up step, the related page can help you move to the next tool in the workflow.
Open the main JavaScript Prettify page and test your own real input.