Skip to content

JavaScript formatter

Lay out basic JavaScript structure while keeping pasted code as inert text in your browser.

Conservative layout72 chars
Text only · never executed or rendered
The formatter preserves strings and comments as text.
Formatted JavaScript preview Ready
81 output chars
function welcome(name) {
  const message = "Hello, " + name;
  return message;
}
Processed on your device

How it works & useful details

Structural JavaScript layout

This conservative formatter copies strings and comments verbatim, then lays out braces, semicolons, and indentation. It never evaluates pasted text.

It is useful for basic statement and block layout. It is not a full JavaScript parser or a substitute for an ecosystem formatter: retain your source when exact whitespace around complex syntax, regular-expression literals, or automatic-semicolon-insertion boundaries matters.

Private, bounded text processing

Code and markup stay as inert text in this browser. These tools do not execute JavaScript, render HTML, load URLs, install packages, contact registries, or save what you paste.

Regex patterns are limited to 500 characters and test text to 20,000 characters. Formatters and package inspection accept up to 100,000 characters; exports are capped at 200,000 characters.

About this tool

JavaScript formatter applies consistent indentation and line breaks to basic JavaScript structure. It is designed for quick readability passes on snippets, not as a replacement for a full project formatter in your editor.

Pasted code stays inert: it is never evaluated, and no module, package, or URL referenced by the code is loaded. Curly braces inside strings, template literals, or comments are reported when they make the structure ambiguous.

How to use it

  1. Paste the JavaScript you want to lay out.
  2. Run the formatter to indent the structure.
  3. Read any warnings about constructs the bounded formatter did not fully parse.
  4. Copy or download the formatted snippet.

Worked example

function welcome(name){const message = "Hello, " + name;return message;}

is laid out as

function welcome(name) {
  const message = "Hello, " + name;
  return message;
}

Braces open and close blocks, each statement ends up on its own line, and nesting is indented by two spaces. Strings and comments are copied verbatim.

What this formatter is for

Use it to make a minified snippet, a one-line bookmarklet, or code pasted from a log readable enough to understand. The code is treated strictly as text and never executed. That matters for code of unknown origin, where "just running it in the console to see what it does" can be dangerous.

It does not understand the full JavaScript grammar. Regular-expression literals, template literals with nested expressions, and code that relies on automatic semicolon insertion may be laid out imperfectly, and the formatter never renames or reorders anything. For project code, use Prettier or your editor's formatter. For understanding obfuscated code, a proper deobfuscator gives better results.

Frequently asked questions

Does it execute the code or check for errors?

No. It only adjusts layout, and it does not type-check, lint, or run anything you paste.

Does it support JSX, TypeScript, or module syntax?

Not reliably. It targets plain JavaScript structure, so JSX and TypeScript type annotations are laid out as ordinary braces, which can produce odd output such as className= { x } on separate lines. Use Prettier or your editor for JSX and TypeScript.

What is the size limit?

Up to 100,000 characters, with exports capped at 200,000 characters.