Skip to content

Output formats and the JSON envelope ​

tfcensus writes data to stdout and logs to stderr, so tfcensus scan --format json > scan.json captures the report and nothing else. --format picks the format of stdout. Without it, tfcensus prints tty when stdout is a terminal or gets color anyway, and plain otherwise.

FormatOutput
ttya table with color, notes wrapped at the terminal width
plainthe same table without color or wrapping
mdMarkdown, cut at a table row or section once it reaches --md-max-chars (60,000 characters by default, under GitHub's comment limit)
jsonthe JSON envelope below, for scripts
csvcomma-separated values, one row per finding or unit
sarifSARIF 2.1.0, for GitHub code scanning and other SARIF viewers
githubGitHub Actions workflow commands, which show as annotations

A command rejects a format it doesn't have with exit 2.

Color ​

tfcensus decides color once for stdout and once for stderr (the logs). The first rule that applies wins:

  1. --color always or --color never.
  2. NO_COLOR set to anything but an empty string turns color off.
  3. CLICOLOR_FORCE or FORCE_COLOR set to anything but an empty string, 0 or false turns it on, also when the output is a pipe or a file.
  4. CLICOLOR=0 or TERM=dumb turns it off.
  5. Otherwise the stream gets color when it is a terminal.

The tty format uses the 16 basic terminal colors, so it follows your terminal theme, and every colored cell also says what it means in text: unmanaged counts are red, double-managed bold red, undetermined yellow, drifted units yellow and failed ones red, high audit findings red. plain, md, json, csv and the --out files never contain color codes, and neither does a --log-file. COLUMNS sets the wrap width of notes and warnings; tables are never cut.

CI logs are not terminals, so they stay plain, and so do the logs of tfcensus-action. GitHub Actions shows colors in step logs: add --color always or set CLICOLOR_FORCE: "1" on a step whose tty output you read in the log.

AWS resource names, tag values, ARNs, drift values and error messages from AWS, terraform or tofu can contain control characters. The tty and plain formats show them in caret notation (^[ for escape), so text from outside can't move the cursor, change the window title or write the clipboard.

When stdout is a pipe that closes early, as in tfcensus scan | head -3, tfcensus stops writing stdout, still writes the --out files and exits with the code it would have used.

Formats per command ​

The report commands also take a repeatable --out format=path, so one run writes several formats, such as --out json=scan.json --out sarif=scan.sarif, and still prints to stdout. --out takes every format of the command except tty.

CommandFormats--outJSON schema
audit backendtty, plain, md, json, csv, sarif, githubyesaudit-v1.json
cache cleartty, plain, json
cache infotty, plain, json
codifytty, plain, jsoncodify-v1.json
config pathtty, plain, json
config showtty, plain, json
config validatetty, plain, json
doctortty, plain, md, json
drifttty, plain, md, json, sarif, githubyesdrift-v1.json
inventorytty, plain, md, json, csvyesinventory-v1.json
move applytty, plain, json, sarif
move mark-appliedtty, plain, json
move plantty, plain, json, sarif
move rollbacktty, plain, json
move statustty, plain, json
move suggesttty, plain, jsonmove-suggest-v1.json
notifytty, plain, json
report audittty, plain, json
report drifttty, plain, json
report inventorytty, plain, json
report scantty, plain, json
report unitstty, plain, json
rules testtty, plain, json
scantty, plain, md, json, csv, sarif, githubyesscan-v1.json
unitstty, plain, md, jsonyes
versiontty, plain, json
whoistty, plain, md, json, sarifyeswhois-v1.json

The JSON envelope ​

Every --format json output, every --out json= file and every MCP tool result is one JSON object with the same fields around the command's data:

FieldTypeMeaning
schema_versionstringThe envelope version, "1". A change that breaks readers increases it.
toolstring"tfcensus".
versionstringThe tfcensus version that wrote the output.
generated_atstringWhen the output was written, in RFC 3339 UTC to the second.
dataobjectThe command's result. Its shape is in the command's schema.
errorsarrayProblems with one target that didn't stop the run, each with target (such as a unit or account) and message. Empty when there were none.
pageobjectOnly in MCP results that are split into pages: items, returned, total and next_cursor.

report-v1.json is the envelope's schema, and each command with its own schema in the table above extends it. The JSON schemas page lists them all.

A change that would break a reader, such as renaming or removing a field, increases schema_version. New fields can appear without it, so read the output with a parser that ignores unknown fields. tfcensus is before 1.0, and the changelog lists each change.

The data holds identifiers, never state attribute values (safety model).

Saved reports ​

The JSON output of scan, drift and audit backend is also the input of report, notify, report html and mcp, and inventory --save-index writes the index that whois --index and report units read. None of these commands calls AWS.