{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"redocly_category":"Treasure Code","product_name":"Treasure Code","type":"markdown"},"seo":{"title":"Output Formats - tdx | Treasure Data","description":"Configure tdx output formats including table, JSON, JSONL, and TSV for query results and command outputs.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]},"image":"/assets/og-image.ba836864a30434f560a4f7720f8a09019ad30ff828b20c5052ae933ba7121524.d7ef4821.png"},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"output-formats","__idx":0},"children":["Output Formats"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["tdx supports multiple output formats for query results and command outputs."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"format-options","__idx":1},"children":["Format Options"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Option"},"children":["Option"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["(default)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Human-readable table (vertical layout for single objects)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--table"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Horizontal table layout (forces table even for single objects)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--json"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Readable JSON array"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--jsonl"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["JSON Lines (one object per line)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--tsv"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Tab-separated values"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"table-format-default","__idx":2},"children":["Table Format (Default)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Human-readable ASCII table with column types and row counts:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"tdx query \"SELECT name, age FROM users LIMIT 2\"\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"┌────────┬─────┐\n│  name  │ age │\n│ string │ int │\n├────────┼─────┤\n│ Alice  │  25 │\n│ Bob    │  30 │\n├────────┴─────┤\n│ 2 rows       │\n└──────────────┘\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Numbers are right-aligned, strings are left-aligned."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"json-format","__idx":3},"children":["JSON Format"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Readable JSON array with newlines (no metadata):"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"tdx query \"SELECT name, age FROM users LIMIT 2\" --json\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"[\n  {\"name\":\"Alice\",\"age\":25},\n  {\"name\":\"Bob\",\"age\":30}\n]\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Perfect for piping to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["jq"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"tdx query \"SELECT * FROM users\" --json | jq '.[0]'\ntdx query \"SELECT * FROM users\" --json | jq 'length'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"json-lines-format","__idx":4},"children":["JSON Lines Format"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["One JSON object per line - ideal for streaming and line-by-line processing:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"tdx query \"SELECT name, age FROM users LIMIT 2\" --jsonl\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\"name\":\"Alice\",\"age\":25}\n{\"name\":\"Bob\",\"age\":30}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Process line by line:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"tdx query \"SELECT * FROM users\" --jsonl | while read line; do\n  echo \"$line\" | jq '.name'\ndone\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"tsv-format","__idx":5},"children":["TSV Format"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Tab-separated values with header row:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"tdx query \"SELECT name, age FROM users LIMIT 2\" --tsv\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"name\tage\nAlice\t25\nBob\t30\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"color-output","__idx":6},"children":["Color Output"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["tdx automatically adds ANSI colors to output in interactive terminals:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Table format:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Table borders: Dark gray (dim)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Column headers: Plain text"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Type row: Dim gray"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Data values: Plain text"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["JSON format:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Keys: Blue"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Strings: Green"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Numbers: Cyan"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Booleans: Yellow"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Null values: Dim"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"automatic-detection","__idx":7},"children":["Automatic Detection"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Colors are enabled automatically when output is to an interactive terminal (TTY)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Colors are disabled automatically when:",{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Output is piped to another command"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Output is saved to a file with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--output"]}]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Respects the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["NO_COLOR"]}," environment variable"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"manual-control","__idx":8},"children":["Manual Control"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# Force colors on (even when piping or saving to file)\ntdx databases --color\n\n# Disable colors (even in interactive terminal)\ntdx databases --no-color\n\n# Disable colors via environment variable\nNO_COLOR=1 tdx databases\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"interactive-table-navigation","__idx":9},"children":["Interactive Table Navigation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When viewing table output in an interactive terminal, tdx automatically pipes output through ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["less"]}," for easy navigation:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Key"},"children":["Key"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Action"},"children":["Action"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["q"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Quit and return to terminal"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["↑"]}," / ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["↓"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Scroll up/down one line"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Space"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Scroll down one page"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["b"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Scroll up one page"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["←"]}," / ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["→"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Scroll left/right (for wide tables)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/pattern"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Search forward"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["n"]}," / ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["N"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Repeat search forward/backward"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["g"]}," / ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["G"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Go to first/last line"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Less pagination is disabled when:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Output is piped to another command"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Output is saved to a file with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--output"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Using non-table formats (JSON, JSONL, TSV)"]}]}]},"headings":[{"value":"Output Formats","id":"output-formats","depth":1},{"value":"Format Options","id":"format-options","depth":2},{"value":"Table Format (Default)","id":"table-format-default","depth":2},{"value":"JSON Format","id":"json-format","depth":2},{"value":"JSON Lines Format","id":"json-lines-format","depth":2},{"value":"TSV Format","id":"tsv-format","depth":2},{"value":"Color Output","id":"color-output","depth":2},{"value":"Automatic Detection","id":"automatic-detection","depth":3},{"value":"Manual Control","id":"manual-control","depth":3},{"value":"Interactive Table Navigation","id":"interactive-table-navigation","depth":2}],"frontmatter":{"seo":{"title":"Output Formats - tdx | Treasure Data","description":"Configure tdx output formats including table, JSON, JSONL, and TSV for query results and command outputs.","image":"/assets/og-image.ba836864a30434f560a4f7720f8a09019ad30ff828b20c5052ae933ba7121524.d7ef4821.png"}},"lastModified":"2026-02-14T00:54:05.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/treasure-code/guide/output-formats","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}