A minified function
- JavaScript code
- function add(a,b){return a+b;}
- Indent with
- 2 spaces
Result Beautified code: function add(a, b) {
return a + b;
}
Lines: 3
Tokens: 14
Comments: 0
Characters: 38
- Split the source into 14 tokens: words, numbers, strings, template literals, regular expressions, comments and operators.
- Opened a new line after each { and statement-ending ;, closed each } on its own line, and indented every level with 2 spaces.
- Put single spaces around binary operators and after commas; strings, regexes and comments are copied unchanged.
The body moves onto its own indented line, a space follows the comma, and the + operator gets a space on each side.