gofmt vs Prettier
gofmt
go.devPrettier
prettier.ioSide by side
| Figure | gofmt | Prettier |
|---|---|---|
| Price from | Free | Free |
| Free plan | Yes | Yes |
| Free trial | — | — |
| Open source | — | Yes |
| Web | — | Yes |
| Windows | Yes | Yes |
| macOS | Yes | Yes |
| Linux | Yes | Yes |
| API | — | Yes |
| Self-hosted | — | Yes |
| Plans published | 1 | 2 |
| Spec score · Code Formatting Tools | 7.8 (#13) | 8.5 (#2) |
| Editor integrations | The Go project documents gofmt integrations for Vim, Emacs, Eclipse, Sublime Text, Git pre-commit hooks, and Mercurial. | The official site lists integrations or support for VS Code, WebStorm, Visual Studio, Vim, Emacs, Sublime Text, Nova and Espresso. |
Plans
In their own words
gofmt
gofmt is the Go source formatter distributed with Go installations, available on Linux, macOS, and Windows. It formats Go programs using tabs for indentation and spaces for alignment. With no path, it reads standard input; given a directory, it processes .go files recursively while skipping files whose names begin with a period. By default, reformatted source is written to standard output. Flags can show differences, list files that need formatting, apply rewrite rules, simplify code, or report all errors. The rewrite option uses patterns and replacements written as valid Go expressions. gofmt can also arrange documentation comments into canonical paragraphs, lists, headings, links, and code blocks. The Go project documents integrations for Vim, Emacs, Eclipse, and Sublime Text, plus Git pre-commit hooks and Mercurial. Since Go 1.18, it reads and formats files concurrently, with memory use limited in proportion to GOMAXPROCS. The executable is equivalent to go fmt. It is free, included in the Go installation, and distributed under a BSD-style license.
Prettier
Prettier is an open-source code formatter that parses source files and prints them in a consistent style while accounting for line length. Its built-in languages include JavaScript, JSX, Angular, Vue, Flow, TypeScript, CSS, Less, SCSS, HTML, JSON, GraphQL, Markdown, YAML, LWC, and MJML. The command-line interface can write formatted files with --write or check formatting with --check in continuous integration. Listed editor integrations include VS Code, Emacs, Vim, Helix, Sublime Text, JetBrains IDEs, Visual Studio, and Espresso; formatting can run from a shortcut or on save. Prettier has configuration options but keeps them limited. Plugins can add languages and formatting rules, and languages outside the built-in set require a plugin. For ESLint integration, the installation guidance recommends eslint-config-prettier to disable rules that are unnecessary or may conflict. Prettier supports browser and JavaScript API use, along with Linux, macOS, and Windows. The listed plan is free. Commercial support and maintenance are available through the Tidelift Subscription.