JavaScript Formatter
Beautify JavaScript, TypeScript and JSX code.
JavaScript Formatter
Developer tool running locally in browser
What does JavaScript Formatter do?
Format JavaScript, TypeScript, JSX and TSX with a real parser rather than regular expressions, so the output is always syntactically identical to the input. Configurable indentation, quotes, semicolons and line width.
How to Use JavaScript Formatter
- 1Paste your codeJS, TS, JSX or TSX.
- 2Set your preferencesIndentation, quotes, semicolons, line width.
- 3Copy the formatted codeOr download it as a file.
Key Features
- Parses the code properly, so formatting can never change behaviour
- JavaScript, TypeScript, JSX and TSX all supported
- Configurable indent width, quote style, semicolons and print width
- Syntax errors reported with the exact position
- Formatter loaded only when you use it, so it does not slow the page down
Frequently Asked Questions
Can formatting break my code?
No. The code is parsed into a syntax tree and printed back out, so the program is identical. Only whitespace, quote style and line breaks change.
Does it support TypeScript?
Yes, including type annotations, generics, decorators and enums. Select the TypeScript parser so type syntax is understood rather than rejected.
What print width should I use?
80 is the traditional default; 100 or 120 suits modern wide screens. The setting is a guide, not a hard limit — the formatter breaks at sensible points, not mid-expression.
Is my code sent anywhere?
No. The formatter runs in your browser. Nothing you paste is transmitted, which matters for proprietary code.
Input is processed in your browser and never transmitted. That said, treat any web page as untrusted for live production secrets — rotate anything you paste anywhere.
Related Tools
JSON Formatter
Format, validate and explore JSON with precise error reporting.
CSS Formatter
Beautify CSS with consistent indentation and spacing.
HTML Formatter
Beautify or minify HTML with correct indentation.
SQL Formatter
Format SQL queries into readable, consistently indented statements.
