Skip to main content
KalkuNet

JavaScript & TypeScript Beautifier — Clean Indentation for Dense Code

Re-format dense JavaScript code blocks with balanced braces and indentation.

Runs in your browserDeveloper · Formatters, Minifiers & Code Builders
Indentation:
  • The code is read token by token: regexes are told apart from division, template literals with nested ${…} and quoted strings are left alone, and line breaks that decide automatic semicolons (return, ++, --) are kept.
  • The beautifier also reads TypeScript (types, generics, optional properties, as const). The output is tested with esbuild: the original program and the formatted one are exactly the same.

When to use the JavaScript / TypeScript Code Beautifier

  • Reading minified code

    Built scripts or snippets copied from the console are usually one long line. The beautifier writes one statement per line, indents every block and keeps } else, } catch and }); together so the flow is easy to follow while debugging.

  • The program does not change

    The code is read token by token: regexes are told apart from division, template literals with nested ${…} are left alone, and line breaks that decide automatic semicolons, such as after return, are kept. The output is tested with esbuild on pdf-lib, preact and this site's own scripts.

  • TypeScript works too

    Type annotations, generics such as Record<string, number>, optional properties name?: string and as const are read correctly. Hundreds of this site's TypeScript files are formatted and compared with the originals by esbuild, with the same result.

  • Indentation to match your team

    Choose two spaces, four spaces or a tab to match the project's style rules. Line and block comments stay where they were, and multi-line text inside template literals is left untouched.

Frequently asked questions

Are variable names changed?

No. The beautifier only arranges spaces, line breaks and indentation.

Is JSX supported?

Not fully. JSX is read as plain text so its indentation may be untidy; the logic and strings around it stay safe.

What about broken code?

The code is still formatted as far as possible without guessing missing parts. Check your browser's or editor's error message to find the cause.

Is my code uploaded?

No. Everything runs in your browser.

Learn more