Entrada
Salida
Elige una operación para empezar

Formateador Go en línea (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

Comentarios

Este sitio es solo frontal: sin backend ni cuentas. Los comentarios van a GitHub Issues, Discussions o correo.

Pega esto en el issue o correo para ayudarme a localizar el problema; no incluye nada de lo que escribiste

También:Ver comentarios existentes · Comentarios por correo (sin cuenta de GitHub):278975598@qq.com