Before
inputfunction dart(){return true}Formatter
Compare the exact input shape with the cleaned output before opening the editor.
Before
inputfunction dart(){return true}After
formattedfunction dart() {
return true
}Workflow
Paste a snippet, run the action, review any highlighted issue, then copy the result back to your work.
Paste a snippet or full file into the editor.
Use Run Formatter from the action bar.
Fix syntax issues if processing stops.
Use Copy code when the result is ready.
Dart formatting guide
Dart is unusual: the language ships with an official formatter, dart style, and the community follows it almost universally. This page runs a WebAssembly build of the same rule set, so results match dart format - in your browser, with no upload.
The formatter uses a greedy line-splitting algorithm over the parsed tree. The visible outcomes are stable: 2-space indentation, spaces inside braces, 80-column target width, and trailing commas added wherever a construct would otherwise split.
Because formatting starts from a parse, the output is canonical: two developers formatting the same file always get identical text. That is why Dart teams simply commit the output and skip style review.
| Rule | Value | Effect |
|---|---|---|
| Indentation | 2 spaces | Never tabs. |
| Page width | 80 columns | Constructs that do not fit split onto lines. |
| Trailing commas | Added automatically | Forces a split for lists, maps, and argument lists. |
| String style | Preserved | Quotes and interpolation are not rewritten. |
The Dart and Flutter VS Code extensions format on save once formatOnSave is enabled - there is nothing extra to install. On the command line, dart format . rewrites every file under the current directory.
Use this page for code that lives outside a package: snippets from issues, samples from documentation, or quick checks on generated code.
In Dart, a trailing comma is a formatting instruction. When a list of arguments or collection elements ends with a comma, the formatter always splits it one item per line; without the comma, it keeps items on one line when they fit.
Teams that want vertical widget trees in Flutter add the comma; teams that prefer compact calls remove it and let the width rule decide. The formatter never removes your trailing commas - it only adds them where a split already happened.