---
title: "How we built a new powerful JSON data type for ClickHouse"
description: "ClickHouse's new JSON type stores every JSON path as a true columnar, dense subcolumn, built on two standalone building blocks: Variant and Dynamic."
url: "https://swe.quest/articles/how-we-built-a-new-powerful-json-data-type-for-clickhouse-cd5f151dcedf8d3e"
canonical: "https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse"
source: "ClickHouse"
published: "2024-10-22"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 17
tags: ["storage-engines","analytics","databases"]
---

# How we built a new powerful JSON data type for ClickHouse

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2024-10-22, 17 min read, Deep dive. Original: [https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse](https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse)

## Summary

ClickHouse's new JSON type stores every JSON path as a true columnar, dense subcolumn, built on two standalone building blocks: Variant and Dynamic. Variant keeps mixed-type values in per-type column files without coercing them to a common type, using a UInt8 discriminator column (255 reserved for NULL) and in-memory offsets to locate values. Dynamic removes the need to declare types up front and caps separately stored types with max\_types (default 32). Types beyond the cap go into a binary-encoded SharedVariant string column, which keeps sparse or high-cardinality JSON from producing an avalanche of column files on disk.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Storage engines](https://swe.quest/tags/storage-engines.md) (Data & databases)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)

## Prerequisites

- columnar storage
- ClickHouse MergeTree ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))
- JSON data model

## Keywords

ClickHouse, JSON, Variant type, Dynamic type, MergeTree, SharedVariant

## Related posts

- [Getting Data Into ClickHouse - Part 2 - A JSON detour](https://swe.quest/articles/getting-data-into-clickhouse-part-2-a-json-detour-fe37737f4af7d8af.md): ClickHouse · 2022-09-01 · Medium · 9 min read · Analytics & OLAP, Databases, SQL
  ClickHouse's experimental JSON (Object('json')) type, introduced around 22.8, stores semi-structured rows by automatically inferring sub-columns and representing them internally as Tuples with minimal-width numeric types.
- [ClickHouse Newsletter April 2022: JSON, JSON, JSON](https://swe.quest/articles/clickhouse-newsletter-april-2022-json-json-json-d21f592453b8c7ef.md): ClickHouse · 2022-04-14 · Medium · 5 min read · Analytics & OLAP, Databases, SQL
  ClickHouse 22.3 LTS adds an experimental JSON data type that stores semi-structured documents in a single column, with dynamic subcolumns underneath, so you no longer need hand-built schemas of arrays and materialized columns.
- [ClickHouse Release 24.5](https://swe.quest/articles/clickhouse-release-24-5-28a1e020a76b65db.md): ClickHouse · 2024-06-05 · Medium · 10 min read · Analytics & OLAP, Query engines, SQL, Performance engineering
  ClickHouse 24.5 adds an experimental Dynamic data type for semi-structured columns that accepts values of any type without declaring them upfront like Variant, and queries them via dynamicType, dynamicElement and dot syntax.
- [Making complex JSON 58x faster, use 3,300x less memory, in ClickHouse](https://swe.quest/articles/making-complex-json-58x-faster-use-3-300x-less-memory-in-clickhouse-7431021b1253a468.md): ClickHouse · 2025-10-09 · Hard · 7 min read · Storage engines, Analytics & OLAP, Performance engineering
  ClickHouse v25.8 adds two new on-disk serializations for the JSON type's shared data, which holds paths beyond the 1,024 dynamic-subcolumn limit.
- [ClickHouse Release 24.8 LTS](https://swe.quest/articles/clickhouse-release-24-8-lts-0a43fff10e32a288.md): ClickHouse · 2024-09-03 · Medium · 14 min read · Analytics & OLAP, Databases, SQL
  ClickHouse 24.8 is a Long Term Support release (supported for 12 months) with 19 new features, 18 performance optimisations and 65 bug fixes.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
