Sign up free

JS Beautifier and JavaScript Formatter

Paste minified or messy JavaScript and get one statement per line, with every block indented.

About JavaScript Formatter

A JS beautifier turns a wall of code into something you can follow. It helps when you debug a minified library, read a script a plugin adds to your pages, tidy code pasted from a forum answer, or check what a third-party tracking snippet does before you add it to your site. Paste the code or open a .js file, and the formatted version appears as you type.

Each statement gets its own line, and blocks and objects are indented with 2 spaces, 4 spaces or tabs. The formatter understands strings, template literals, regular expressions and comments, so a brace or slash inside them doesn't throw the layout off. Your semicolons are kept as they are: none are added and none are removed. Names that a minifier shortened to single letters stay short, because formatting can't bring the originals back. When you need the file small again, use the JavaScript Minifier. The code never leaves your browser.

How to use JavaScript Formatter

  1. 1
    Paste your JavaScript

    Paste the code or open a .js file.

  2. 2
    Choose the indent

    Pick 2 spaces, 4 spaces or tabs, and the JavaScript formatter updates the result live.

  3. 3
    Copy or download

    Copy the formatted code or download it as a file.

Why use Cubfile for this

  • Reads the syntax

    Strings, template literals, regular expressions and comments are recognized, not guessed at.

  • One statement per line

    Statements go on their own lines, and blocks and objects are indented.

  • Semicolons untouched

    Code with or without semicolons keeps its style.

  • Private

    Runs in your browser, so the code is never uploaded or stored.

FAQ

JavaScript Formatter: questions and answers

How do I unminify JavaScript?
Paste the minified code or open the .js file and pick an indent. Statements are split onto their own lines and blocks are indented, ready to copy or download. Minified stylesheets can be spread out the same way with the CSS Formatter.
Can the JavaScript formatter restore the original variable names?
No. Once a build tool has renamed variables to a, b or c, the original names are gone from the file. Formatting restores the layout, not the names.
Does formatting add or remove semicolons?
Neither. Only spaces, line breaks and indentation change, so code written without semicolons stays that way.
Will regular expressions and template literals get mangled?
No. They're recognized along with strings and comments, so braces, quotes and slashes inside them aren't mistaken for code.
Does the JS beautifier upload my code?
No. Formatting runs in your browser, with no sign-up and no daily limit, and it works offline once the page has loaded.
Share JavaScript Formatter with a friendIt runs in any browser, and they can try it without signing up.

Related tools

HTML HTML FormatterIndent messy HTML so it’s easy to read.
HEX Color ConverterConvert colors between HEX, RGB, HSL and CMYK, and check contrast.
CRON Cron Expression GeneratorBuild cron expressions and see the next run times in plain words.
CSS CSS FormatterTurn minified CSS into neat, readable rules.
CSS CSS MinifierMinify CSS to load faster.
HTML HTML MinifierShrink HTML by removing comments and extra whitespace.
HTTP HTTP Request TesterSend GET, POST and other requests to a public API and read the response.
JS JavaScript MinifierStrip comments and whitespace from JavaScript without changing how it runs.