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

1

Paste your Dart code

Drop unformatted Dart, whether a widget build method or a model class, into the left editor, or open a .dart file with Upload.

2

Formats as you type

The formatter automatically normalizes indentation with 2 spaces per level and fixes brace alignment.

3

Copy or download

Send the formatted code back to your IDE via Copy, or Download 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. Re-indenting is a few lines of script that run in this tab without any network call, so an unreleased Flutter widget, or a file that still has an API key in it, stays on your machine. Close the tab and it is gone.

Related Tools