Documentssuperset
Chart Export Serialization
Chart Export Serialization
Type
Topic
Status
Published
Created
Jul 27, 2026
Updated
Jul 27, 2026
Created by
Dosu Bot
Updated by
Dosu Bot

Chart Export Serialization#

Chart export in Superset is handled by ExportChartsCommand, which extends the generic ExportModelsCommand base class. Calling run() produces an iterator of (filename, content_callable) tuples that form a ZIP archive: a metadata.yaml header, one YAML file per chart under charts/, and any related dataset and tag YAMLs.


Serialized Fields#

The canonical set of chart fields comes from Slice.export_fields:

FieldNotes
slice_nameChart display name
description
certified_by
certification_details
datasource_typeRemoved post-export (see below)
datasource_nameRemoved post-export (see below)
viz_typeVisualization type identifier
paramsFull chart config as a JSON blob
query_contextSerialized query context
cache_timeout

These fields are extracted by ImportExportMixin.export_to_dict(), the shared base-class method called with recursive=False, include_defaults=True, export_uuids=True.

After export_to_dict() runs, ExportChartsCommand._file_content() applies two further transformations:

  1. Key removalREMOVE_KEYS = ["datasource_type", "datasource_name", "url_params"] are stripped . datasource_type and datasource_name are redundant once dataset_uuid is present; url_params are environment-local.
  2. params JSON expansion — The params string is decoded into a Python dict before YAML serialization, so the chart config is human-readable YAML rather than an escaped JSON string .

Three fields are then appended by the export command itself:

  • version — always set to EXPORT_VERSION = "1.0.0"
  • dataset_uuid — UUID of the linked SqlaTable, if present
  • tags — custom tag names when the TAGGING_SYSTEM feature flag is enabled

The two fields is_managed_externally and external_url are listed in extra_import_fields — they are accepted on import but are not exported.


color_scheme and Dashboard-Level Metadata#

color_scheme is not a top-level chart field. It is a dashboard-level property, stored in Dashboard.json_metadata and managed through the dashboard DAO . Standalone chart exports do not include it.

A color_scheme key can appear inside the params JSON blob for chart types that support per-chart color theming — this is purely a visualization preference attached to the chart itself, distinct from the palette applied at dashboard level. Because params is exported wholesale, any per-chart color preference round-trips through export/import.

Dashboard-level color schemes are exported only by ExportDashboardsCommand, which serializes Dashboard.export_fields including json_metadata.


Export Flow#

ExportModelsCommand.run()
  └─ yields metadata.yaml
  └─ for each Slice:
       ExportChartsCommand._export(model)
         ├─ _file_content(model) → charts/<name>.yaml
         ├─ ExportDatasetsCommand(...) → datasets/<name>.yaml (if export_related)
         └─ ExportTagsCommand(...) → tags YAML (if TAGGING_SYSTEM enabled)


Import#

import_chart() in superset/commands/chart/importers/v1/utils.py reverses the process:

  1. Looks up the chart by uuid; checks write permissions and ownership before overwriting.
  2. Calls filter_chart_annotations() — mutates params to keep only FORMULA-type annotation layers (EVENT and other types are dropped).
  3. Re-serializes params from dict back to a JSON string .
  4. Calls migrate_chart() to upgrade legacy viz types.
  5. Calls Slice.import_from_dict() , which gates field acceptance to export_fields + extra_import_fields — preventing injection of arbitrary columns.

Key Source Files#

FilePurpose
superset/commands/chart/export.pyExportChartsCommand — serialization logic
superset/commands/export/models.pyExportModelsCommand — base iterator/dedup logic
superset/models/slice.pySlice model, export_fields, extra_import_fields
superset/models/helpers.pyImportExportMixin.export_to_dict() / import_from_dict()
superset/commands/chart/importers/v1/utils.pyimport_chart() — deserialization and migration
superset/utils/dict_import_export.pyEXPORT_VERSION constant
superset/daos/dashboard.pyDashboard color_scheme in json_metadata