All documents

ModelFormatApp

spicegrinder-icon

© 2026 Obsvra. This document describes SpiceGrinder and is provided to help you evaluate and use it. It is not a license to reproduce, adapt, or use this material to build a competing product or service. Full terms: the SpiceGrinder EULA.

NAME

ModelFormatApp — rewrite model files in the standard layout

SYNOPSIS

java -cp spicegrinder.jar com.obsvra.spicegrinder.tools.ModelFormatApp [--check] model [model ...]
java -cp spicegrinder.jar com.obsvra.spicegrinder.tools.ModelFormatApp [--check] -

On a jpackage install:

format [--check] model [model ...]

On Windows, format alone runs the Windows disk format command, because the system folders come first on PATH. Use format-model, which the desktop app’s full install adds as another name for this tool, or give the full path to format.exe.

DESCRIPTION

format rewrites XML, JSON and compact (.sgm) model files in one consistent layout, so that version-control diffs show only real changes, never formatting noise. It changes layout and attribute order only. It never changes what a model means, the order of its nodes, or its comments. Nothing reformats a model unless you run format; the desktop app saves your file as you wrote it.

Without --check, each file that isn’t already formatted is rewritten in place and named on standard output. With --check, nothing is written: each file that would change is named, and the exit status says whether any would. - reads a model from standard input and writes the formatted model to standard output (the format is recognized from its first character).

A compact model is rewritten by the compact writer, which is its house style. Every comment block is kept with what it belongs to: the file’s header, the block above each directive line and each node, and the block at the end of the file. (A comment on the same line as a statement is not valid compact syntax.) As a safety net, format refuses a file, saying so, rather than drop a comment or write something that isn’t stable. On standard input, a first character other than < or { is read as compact.

OPTIONS

  • --check: write nothing; name each file that isn’t formatted, and exit 1 if any.
  • --version: print the version.
  • -h, --help: show usage.

STYLE

Both formats:

  • Attribute order. name first. Then the component’s parameters in the order the component documents them (the order in Component-Library-Reference.md and list --component). An alias sorts where its parameter does and keeps the spelling you used (stddev stays stddev). Then synchronous (or sync), then any other attribute alphabetically, then the analysis.* attributes analyze writes, in the order it writes them. A component format doesn’t know (a custom class not on the classpath, or a Pro component when running the Free edition) gets name first and the rest alphabetically.
  • <input> attributes. name, then the order the component declares for them (for example Mix’s weight).
  • Node order stays exactly as written.
  • Values are unchanged. A value’s text is rewritten only where the file’s syntax requires (escaping).

XML:

  • An <?xml version="1.0" encoding="UTF-8"?> declaration, then one element per line, indented with one tab per level.
  • The model format’s own elements in their order as written: <dataset> (seed, then random, then other attributes), <root node>, <definitions> (<custom name class>, <declare name value>) and <nodes>.
  • Double quotes; &, <, > and " escaped in attribute values, and tab, newline and carriage return as character references.
  • A tag that would be longer than 100 columns (a tab counting as 4) keeps its first attribute on the tag’s line and puts each of the rest on its own line, one level deeper. One attribute per line diffs cleanly.
  • An element with no content is self-closed: <Normal name="V" mean="0" sigma="1"/>.
  • Comments stay where they are, indented to their level; a comment’s own lines are kept as written.
  • Processing instructions, such as <?xml-model href="spicegrinder-model.xsd"?> after the declaration, stay where they are, on their own line.
  • Where you left a blank line between two elements or comments, one blank line is kept; more become one, and none are added.
  • An element holding text keeps its text exactly (CDATA sections stay CDATA).

A line break inside an attribute value can’t be kept: the XML standard turns it into a space before any program sees the value, so a value written across several lines comes out on one line.

JSON:

  • Two spaces per level, the layout SpiceGrinder itself writes JSON models in.
  • dataset keys: seed, random, any other dataset settings as written, then root, definitions, declarations, nodes.
  • Each node: type, name, attributes, inputs, children, then any other keys as written. attributes on one line in attribute order (above), or one per line when that line would pass 100 columns; each input on its own line; definitions and declarations one per line.
  • Numbers, true, false and null exactly as written (42 stays 42); strings keep their escapes.

EXIT STATUS

  • 0: every file is formatted (or now is).
  • 1: --check found a file that isn’t formatted.
  • 2: bad arguments, or a file that can’t be read, written or parsed.

EXAMPLES

Format a model in place:

format model.xml

Check a model before a commit, alongside validation and analysis:

validate model.xml && analyze --no-write model.xml && format --check model.xml

Format a model on its way through a pipe:

format - < draft.xml > model.xml

SEE ALSO

ModelValidatorApp.md, ModelAnalyzerApp.md, Model-File-Format-Reference.md, Component-Library-Reference.md