Input
Output
Choose an operation to start

Go Formatter Online (gofmt)

Paste Go source code, hit Format, and get exactly what gofmt produces: tab indentation, aligned operators, grouped imports and struct fields lined up by the longest name. The rules come from real gofmt, not a regex approximation.

The formatting engine is Go's official go/format package compiled to WebAssembly, so every calculation happens in your browser and your code is never sent anywhere. That is the difference from most "online formatters" — it keeps working offline, and pasting company code carries no leak risk.

Features

How to use

  1. Paste Go source code into the left editor, or click "Example" to load an unformatted demo.
  2. Click "Format" — the gofmt output appears on the right immediately.
  3. Click "Copy" to put the result on your clipboard, or "Download" to save it as a .go file.
  4. If a syntax error is reported, fix the line:column it points to and format again.

FAQ

Is my code uploaded to a server?

No. The formatting engine is Go compiled to WebAssembly and runs in your browser; the page contains no code that sends your source anywhere. You can disconnect from the network and keep using this page (the first load needs the network to fetch the wasm engine file).

Is the output identical to the command-line gofmt?

Yes. The engine is Go's official go/format package and applies the same rules as go fmt. The only difference is that the CLI version reads and writes files, while this tool works on pasted text.

Why are there no options for indent width or quote style?

Because gofmt's design philosophy is "no configuration" — every Go codebase in the world looks the same, and that is precisely its value over other languages' formatters. This tool deliberately offers no knobs either.

Does it organise imports like goimports?

No. goimports adds and removes imports based on dependency information, which cannot be fully done in a pure front end. This tool only formats, exactly like gofmt. Read the site blog post "gofmt vs goimports" for the difference.

How large a file can it handle?

Files of a few hundred KB are no problem (a 3000-line file formats in about 130 ms in testing). For anything larger, use the command-line gofmt — the editor input experience reaches its limits first anyway.

Related tools & reading

Feedback

This site is front-end only — no backend, no accounts — so feedback goes to GitHub Issues, Discussions, or email.

Paste it into the issue or email to help track it down — it never includes anything you typed

Also:Browse existing issues · Email feedback (no GitHub account needed):278975598@qq.com