> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-3a82795f.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Parses data from arguments according to specified input format. If structure argument is not specified, it's extracted from the data.

# format

Parses data from arguments according to specified input format. If structure argument is not specified, it's extracted from the data.

<h2 id="syntax">
  Syntax
</h2>

```sql theme={null}
format(format_name, [structure], data)
```

<h2 id="arguments">
  Arguments
</h2>

* `format_name` — The [format](/reference/formats) of the data.
* `structure` - Structure of the table. Optional. Format 'column1\_name column1\_type, column2\_name column2\_type, ...'.
* `data` — String literal or constant expression that returns a string containing data in specified format

<h2 id="returned_value">
  Returned value
</h2>

A table with data parsed from `data` argument according to specified format and specified or extracted structure.

<h2 id="examples">
  Examples
</h2>

Without `structure` argument:

```sql title="Query" theme={null}
SELECT * FROM format(JSONEachRow,
$$
{"a": "Hello", "b": 111}
{"a": "World", "b": 123}
{"a": "Hello", "b": 112}
{"a": "World", "b": 124}
$$)
```

```response title="Response" theme={null}
┌───b─┬─a─────┐
│ 111 │ Hello │
│ 123 │ World │
│ 112 │ Hello │
│ 124 │ World │
└─────┴───────┘
```

```sql title="Query" theme={null}
DESC format(JSONEachRow,
$$
{"a": "Hello", "b": 111}
{"a": "World", "b": 123}
{"a": "Hello", "b": 112}
{"a": "World", "b": 124}
$$)
```

```response title="Response" theme={null}
┌─name─┬─type──────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐
│ b    │ Nullable(Float64) │              │                    │         │                  │                │
│ a    │ Nullable(String)  │              │                    │         │                  │                │
└──────┴───────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘
```

With `structure` argument:

```sql title="Query" theme={null}
SELECT * FROM format(JSONEachRow, 'a String, b UInt32',
$$
{"a": "Hello", "b": 111}
{"a": "World", "b": 123}
{"a": "Hello", "b": 112}
{"a": "World", "b": 124}
$$)
```

```response title="Response" theme={null}
┌─a─────┬───b─┐
│ Hello │ 111 │
│ World │ 123 │
│ Hello │ 112 │
│ World │ 124 │
└───────┴─────┘
```

<h2 id="related">
  Related
</h2>

* [Formats](/reference/formats)
