JavaScript Formatter

Free

Format and prettify JavaScript code with Prettier

JSJavaScript
Formatted
function add(a,b){
  return a+b;
}
const x=add(1,2);

About JavaScript Formatter

JavaScript pulled from a bundle, a gist, or a quick experiment can have erratic spacing, inconsistent semicolons, and cramped lines that slow you down. The JavaScript Formatter runs your code through Prettier to apply consistent indentation, spacing, and line breaks, producing clean output that follows widely accepted style conventions.

Paste your script and the tool reformats it instantly without changing what it does. It's free, runs in your browser, and needs no signup. Use it to standardize a messy file, make minified or copied code readable, or apply a consistent style to a snippet before dropping it into your project, so your codebase stays clean and easy for the whole team to follow.

Common uses

  • Apply consistent Prettier style to a snippet before adding it to your project
  • Reformat a chunk of code copied from a tutorial or gist with odd spacing
  • Make a lightly minified script readable enough to understand and modify
  • Clean up a quick prototype so it matches your team's formatting conventions
  • Standardize indentation and quotes across a file pasted from another editor

How to use

  1. 1

    Enter your details

    Type or paste your content and pick a type using the fields below.

  2. 2

    Customise the output

    Adjust the available options — size, colour and other settings — to suit your needs.

  3. 3

    Download or copy

    Your result is generated instantly in your browser. Download it or copy it directly to your device.

Why ToolHub?

  • Clean readable code
  • Standards-compliant formatting
  • One-click beautify

FAQ

What formatting engine does it use?

It uses Prettier, the widely adopted opinionated code formatter, so output matches conventions many JavaScript teams already follow.

Does formatting change my code's behavior?

No. Prettier only rewrites style such as spacing and line breaks. The logic and execution stay the same.

Will it fully unminify obfuscated code?

It restores indentation and spacing, but renamed variables and stripped comments cannot be recovered. It improves readability, not original naming.

Can it format modern syntax like async/await or JSX?

Modern JavaScript syntax is supported. For TypeScript specifically, use the TypeScript Formatter.

Can I use JavaScript Formatter on mobile?

Yes — ToolHub is fully responsive and works on iPhone, Android, tablets and all modern browsers. No app install needed.