Skip to main content
chain
JS
JavaScript Formatter error
Indent
⌃⏎ run · ⎋ clear · / focus input
// about this tool

JavaScript Formatter Online

Updated 2026-10-24

Format and beautify JavaScript online for free. Paste minified or inconsistently indented JS and SnapTools rewrites it with consistent indentation, spacing, and line breaks, ready to copy or download. Everything runs in your browser, so your code is never uploaded.

Minified or bundled JavaScript is a wall of text that is almost impossible to read. Beautifying restores structure without changing a single statement, so you can inspect third-party scripts, review an unfamiliar file, or tidy a snippet before committing, with the behaviour left untouched.

// how to use

  1. 1 Paste minified or messy JavaScript into the input panel on the left.
  2. 2 SnapTools re-indents it with consistent spacing and line breaks as you type.
  3. 3 Choose your indent size, then copy or download the beautified code.

// examples

Minified JS to readable
Input
function add(a,b){return a+b}const x=add(1,2);
Output
function add(a, b) {
    return a + b;
}
const x = add(1, 2);
Compressed object
Input
const u={name:"Ada",roles:["admin","dev"]};
Output
const u = {
    name: 'Ada',
    roles: ['admin', 'dev'],
};

// common uses

Making minified or bundled JavaScript readable for inspection Standardising indentation before committing code Reviewing an unfamiliar script's structure Cleaning up snippets pasted from the web

// faq

Is my code uploaded to a server?
No. Beautifying runs entirely in your browser, so your JavaScript never leaves your machine.
Does it change what my code does?
No. Only whitespace, indentation, and line breaks change; statements, identifiers, and logic are preserved, so the code behaves exactly the same.
Can it handle minified or bundled JavaScript?
Yes. It re-expands minified or single-line JavaScript into readable, indented code, which makes bundled or third-party scripts far easier to inspect.
Does it work with modern syntax?
It handles standard JavaScript including arrow functions, template literals, classes, and object shorthand. Framework-specific syntax like JSX is not its target.
What indent size should I use?
Match your project's style, whether that's four spaces, two spaces, or tabs. The default keeps output readable for most codebases.

Use this via API

Get a free API key →
curl -X POST https://thesnaptools.com/api/v1/tools/js-formatter \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"code":"function add(a,b){return a+b}const x=add(1,2);"}'