Dart Formatter
Format and beautify Dart source code online. Fix indentation and normalize Dart syntax.
Input
Output
What is Dart?
Dart is a client-optimized programming language developed by Google and used as the primary language for Flutter, Google's UI framework for building cross-platform mobile, web, and desktop applications.
The Dart Formatter normalizes indentation (2 spaces per level, following dart format conventions), fixes brace alignment, and removes trailing whitespace.
How to Use
Paste your Dart code
Paste raw or messy Dart source code into the left editor, or click Upload to load a file.
Instant formatting
The formatter automatically normalizes indentation with 2 spaces per level and fixes brace alignment.
Copy or download
Use the Copy button to copy the result, or Download to save it as a .dart file.
Formatting Example
Example: Format a Dart class
Unformatted input:
class User{final String name;final int age;User({required this.name,required this.age});String greet()=>"Hello, ${name}!";}Formatted output:
class User {
final String name;
final int age;
User({required this.name, required this.age});
String greet() => 'Hello, $name!';
}Frequently Asked Questions
Is this compatible with Flutter code?
Yes. Flutter uses Dart as its programming language. This formatter handles standard Dart/Flutter syntax.
What spaces does Dart use?
The official Dart style guide uses 2 spaces for indentation.
Does dart format do more than this?
dart format (formerly dartfmt) performs full AST-based formatting. This tool provides quick indentation-based formatting for online use. You can also explore packages on pub.dev for more Dart tooling.
Is my Dart code safe when I use this tool?
Yes, completely. All formatting happens locally in your browser — no code is ever sent to a server. Your Dart source stays private and secure.