什么是 QML Formatter?
This QML formatter (also useful as a QML beautifier / Qt Quick pretty printer) formats everyday .qml snippets in your browser—no Qt Creator plugin and no server upload. Paste imports, Rectangle/Item trees, property lines, signals, and simple JS bindings; choose 2- or 4-space indent, optionally keep comments, then Format or Minify. It catches unbalanced braces and unterminated strings with line/column when possible. It is not a full qmllint or Qt AST rewriter—complex JS inside functions is indented by braces only. Related tools include JSON, JavaScript, CSS, HTML, GraphQL, and SQL formatters.
如何使用 QML Formatter
- Paste QML into the input (or load the sample).
- Choose 2 or 4 spaces and whether to keep comments / final newline.
- Click Format for readable indentation or Minify to collapse safe whitespace.
- Copy the output into your editor or Qt project.
常见用例
- Cleaning up minified or one-line QML snippets
- Sharing readable Qt Quick examples in docs or PRs
- Quick indent without opening Qt Creator
常见问题
- How do I format QML online?
- Paste your Qt Quick / QML into the input, pick an indent size, and click Format. The tool pretty-prints braces and property lines in your browser.
- Does this work for Qt Quick / Qt 6 QML?
- Yes for typical Qt Quick files (imports, objects, properties, anchors, simple bindings). It does not run QML or match qmllint feature-for-feature.
- Is my QML uploaded to a server?
- No. Formatting and minifying run entirely in your browser. Nothing is sent to a server.
- Can I minify QML?
- Yes. Minify collapses whitespace outside strings and comments while keeping braces balanced. Use Format again if you need readable indent.