JS Formatter
Format, validate, and beautify your JavaScript and TypeScript code with custom semicolons, quotes, and indents.
Formatting
Indent:
Semicolons:
Quotes:
Braces:
Input JS/TS
Formatted JS/TS
What is a JS Formatter?
A JS Formatter is an interactive developer tool that prettifies JavaScript (JS) and TypeScript (TS) code. It parses the syntax, corrects indentation, cleans up spacing around operators, standardizes quotes, and adds or removes semicolons based on user configuration.
Features
- Custom Indentation: Format statements using 2 spaces, 4 spaces, or Tab.
- Semicolon Control: Automatically add or remove semicolons from statements (protecting loop structures).
- Quote Standardization: Convert string literals to Single Quotes (
') or Double Quotes (") consistently. - Parentheses Spacing: Toggle spacing before block parentheses (e.g.
if (cond)vsif(cond)). - Curly Brace Positioning: Place open braces on the same line or on a new line.
Example Input
function greet(user){if(user.isAdmin){console.log('welcome admin');}else{console.log("hello user")}}
Example Output
function greet(user) {
if (user.isAdmin) {
console.log("welcome admin");
} else {
console.log("hello user");
}
}