Last updated
Multi-Language Code Beautification
Code beautification (pretty-printing) reformats source code to follow consistent style conventions: indentation, spacing, line breaks, and bracket placement. Different languages have different conventions and tools. Prettier is the most popular multi-language formatter, supporting JavaScript, TypeScript, CSS, HTML, JSON, YAML, Markdown, and more from a single tool.
Formatters by Language
| Language | Tool | Config File |
|---|---|---|
| JavaScript/TypeScript | Prettier, ESLint | .prettierrc |
| Python | Black, autopep8, isort | pyproject.toml |
| Java | google-java-format, Checkstyle | checkstyle.xml |
| Go | gofmt (built-in) | — |
| Rust | rustfmt (built-in) | rustfmt.toml |
| C/C++ | clang-format | .clang-format |
| CSS/SCSS | Prettier, Stylelint | .stylelintrc |
| SQL | sqlfluff, pgFormatter | .sqlfluff |
Prettier Configuration
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"arrowParens": "avoid",
"endOfLine": "lf",
"overrides": [
{
"files": "*.py",
"options": { "tabWidth": 4 }
}
]
}