Dart Code Formatter

РазработчикТекст
Реклама · УДАЛИТЬ?
dart format default is 80 characters.
Реклама · УДАЛИТЬ?

Гид

Dart Code Formatter

Dart Code Formatter

Paste your Dart or Flutter source and instantly get a cleanly formatted version that follows the conventions enforced by dart format. The formatter runs entirely in your browser — no SDK install, no upload, and no waiting on a remote server. It is a fast, deterministic helper for every situation where you want spec-compliant output without leaving the page.

Как использовать

  1. Paste your Dart or Flutter code into the input area, or click Попробуйте пример to load a sample.
  2. Pick your preferred indent size (2 spaces is the dart_style default, but 4 spaces and tabs are supported).
  3. Перетащите Длина строки slider — the formatter will warn you about lines that exceed your target.
  4. Переключать Sort and group directives, Добавление завершающих запятыхи Collapse blank lines as needed.
  5. Нажмите Формат and copy or download the cleaned-up source.

Возможности

  • Configurable line length — slider from 40 to 160 characters, defaulting to the official 80.
  • dart_style-inspired indentation — supports 2 spaces, 4 spaces, or tabs.
  • Directive grouping — sorts and groups dart:, package:, and relative imports with a blank line between groups.
  • Завершающие запятые — adds a trailing comma to multi-line argument and parameter lists, exactly like Flutter widget trees expect.
  • Null-safety aware — preserves ?., !, ??и ??= with the correct spacing.
  • String-safe — single, double, triple, and raw (r"…") string literals are left untouched.
  • Comment-safe — line, block, and dartdoc (///) comments are preserved and reflowed cleanly.
  • Top-level spacing — inserts a blank line between top-level declarations for readability.
  • 100% клиентская сторона — your code never leaves the browser, so it is safe for proprietary code.

Варианты использования

  • Quick clean-up of a snippet pasted from a Stack Overflow answer or a chat message.
  • Проверки кода on GitHub or GitLab where you want to compare normalized output before commenting on style.
  • Onboarding new developers who do not yet have the Dart SDK installed locally.
  • Pre-commit sanity check when you want to compare your editor’s output to a second-opinion formatter.
  • Flutter widget trees where consistent trailing commas keep diff noise low.

Часто задаваемые вопросы

  1. What style does the formatter follow?

    The formatter mirrors the conventions enforced by dart format (the official tool from the Dart SDK), inspired by the dart_style package. It targets a default line length of 80 characters, applies two-space indentation, normalizes operator spacing, and groups directives in the canonical dart:, package:, then relative order.

  2. Why are trailing commas important in Dart and Flutter?

    A trailing comma at the end of a multi-line argument or parameter list tells the formatter to keep each element on its own line. In Flutter widget trees this dramatically improves readability and produces more meaningful diffs, so the official Dart style guide encourages trailing commas for any list that spans more than one line.

  3. What is dart_style?

    dart_style is the open-source Dart package that powers dart format, the IDE formatters in Android Studio, IntelliJ, and VS Code, and the formatter on dartpad.dev. It applies a deterministic, single-style algorithm so any two correctly-formatted Dart files look identical regardless of who wrote them.

  4. How do null-safety operators like ??, ?., and ! affect formatting?

    Null-aware operators are kept tight to their operands: ?. и ! never have surrounding spaces, while ?? и ??= behave like binary operators with a single space on each side. This matches the behavior of dart_style for sound null safety code.

Хотите убрать рекламу? Откажитесь от рекламы сегодня

Установите наши расширения

Добавьте инструменты ввода-вывода в свой любимый браузер для мгновенного доступа и более быстрого поиска

в Расширение Chrome в Расширение края в Расширение Firefox в Расширение Opera

Табло результатов прибыло!

Табло результатов — это интересный способ следить за вашими играми, все данные хранятся в вашем браузере. Скоро появятся новые функции!

Реклама · УДАЛИТЬ?
Реклама · УДАЛИТЬ?
Реклама · УДАЛИТЬ?

новости с техническими моментами

Примите участие

Помогите нам продолжать предоставлять ценные бесплатные инструменты

Купи мне кофе
Реклама · УДАЛИТЬ?