Readable JavaScript without running it
Paste JavaScript or JSX, or import a UTF-8 JS, MJS, CJS, JSX or TXT file. Choose indentation and select Format JavaScript. Expand advanced options to choose preferred line width, quotes, semicolons and trailing commas. Copy the complete result or download a JS file; JSX syntax uses a JSX download.
The example filters a project list and builds a summary. Formatting can make a compact function easier to read while preserving the meaning of strings, templates, regular expressions and comments. It follows the parsed program, including automatic semicolon insertion; it cannot infer that an accidental newline after return was a mistake.
Useful controls with clear limits
Two or four spaces and tabs are available. Preferred line width is not a hard maximum. Quote preference may yield to fewer escapes; JSX attributes use double quotes. Objects-and-arrays trailing commas are the default. Function-parameter commas require ES2017 or later. Turning semicolons off still allows protective leading semicolons where needed.
This formatter supports JavaScript and JSX, not TypeScript or Flow type annotations. It does not lint, transpile, minify, repair bugs or prove code is safe to execute. Embedded languages inside template strings are not formatted. Test the result in your own project.
Keep the original and recover changes
Your source stays in the input editor. Import, example, clear, large paste and Use output as input offer one Undo replacement, retained across option changes. Undo restores saved formatting and editor-wrap choices with the source text and filename. Ordinary typing clears replacement history and identifies the source as editor text. Edits cancel old processing and disable obsolete downloads. Invalid imports preserve useful work. Syntax errors select the indicated source position; clipboard denial leaves the output selected for manual copying.
Local processing
Code is parsed as text in a local worker, never evaluated, imported as a program or sent to a server. Nothing is saved automatically. Files must use UTF-8; downloads use UTF-8, LF line endings and a final newline. A leading byte-order mark is removed with a notice.
Input is limited to 1 MiB, output to 4 MiB, syntax nodes to 50,000 and syntax depth to 100. Syntax depth counts expression nodes as well as braces. File reading and formatting can be cancelled and have ten-second deadlines.
Uses locally bundled Prettier with its JavaScript parser. Prettier license.