JavaScript Formatter

Format JavaScript online with Prettier. Turn compact functions, objects and modules into readable code without executing your snippet.

JavaScript Formatter helps keep day-to-day snippets tidy with consistent indentation while you iterate on logic.

Input
Output

When to use JavaScript Formatter

  • Tidying event-handler samples
  • Cleaning pasted stack-overflow snippets
  • Standardizing indentation before sharing

Example

Input

const url="https://example.com/a//b";console.log(url)

Output

const url = "https://example.com/a//b";
console.log(url);

How to use

  1. Paste code. Drop the JS you are actively editing.
  2. Format. Run to normalize indentation.
  3. Keep editing. Copy back into your editor or compiler JS pane.

Processing and limitations

Uses the Prettier Babel parser and two-space indentation. Strings and regular expressions are parsed as code rather than edited with whitespace regexes. Formatting does not execute code or check runtime errors.

Reference

Benefits

  • Free to use—no account required
  • Runs in your browser
  • Instant results with no software install
  • Basic processing does not upload your content to a server
  • Always re-test after formatting—especially around template strings and regex literals.

Not the same as

Syntax checking belongs in JavaScript Validator. Shrink files with JavaScript Minifier.

Related tools