About the JavaScript Formatter
Clean up JavaScript, JSX and TypeScript in seconds with Prettier, the formatter used by most modern projects. Choose indentation, line width, quote style and semicolons.
Key features
- JavaScript, JSX, TypeScript and TSX
- Powered by Prettier
- Choose indentation and line width
- Single or double quotes
- With or without semicolons
- Private: your code never leaves your browser
Beautify JavaScript in one click
Paste minified, messy or inconsistently formatted JavaScript or TypeScript and get clean code formatted with Prettier, the formatter used by React, Vue, Next.js and most modern projects.
Before and after
const sum=(a,b)=>{if(!a){return b}return a+b};export default sum
becomes
const sum = (a, b) => {
if (!a) {
return b;
}
return a + b;
};
export default sum;
Options
| Option | Choices |
|---|---|
| Language | JavaScript / JSX, TypeScript / TSX |
| Indent | 2 spaces, 4 spaces, tab |
| Line width | 80, 100, 120 |
| Quotes | Double, single |
| Semicolons | On, off |
Related tools
JavaScript minifier, JSON formatter, and JSON to TypeScript.
How to use the JavaScript Formatter
- Paste your code into the input box, upload a file, or click Sample to try it out.
- Choose the options you want, such as indentation, line width or dialect.
- The result appears instantly in the output panel. Syntax errors are shown with their line and column.
- Click Copy to copy the result, or Download to save it as a file.