Skip to content
PYGWALKER
API Reference
Spec Files

PyGWalker Spec Files

A PyGWalker spec stores chart state. Use spec_path for local files that PyGWalker should load from or save to, and use spec for inline JSON, config IDs, or remote specs.

import pygwalker as pyg
 
walker = pyg.walk(
    df,
    spec_path="./gw_config.json",
    computation="browser",
)

spec_path vs spec

OptionUse forExample
spec_pathLocal chart-state filesspec_path="./gw_config.json"
specInline JSON, config ID, or remote spec URLspec='[{"name":"Chart 1", ...}]'

For new local-file examples, prefer spec_path. It makes file persistence explicit and avoids ambiguity with inline JSON or remote specs.

Save and reuse chart state

Use read-write spec mode when the adapter exposes saving.

import pygwalker as pyg
 
walker = pyg.Walker(
    df,
    spec_path="./gw_config.json",
    spec_io_mode="rw",
    computation="kernel",
)
 
walker.show()

Streamlit and Gradio also support spec_io_mode:

from pygwalker.api.streamlit import StreamlitRenderer
 
renderer = StreamlitRenderer(
    df,
    spec_path="./gw_config.json",
    spec_io_mode="rw",
    computation="kernel",
)
renderer.explorer()

Render saved charts

Use render when you want saved charts without the full explorer.

import pygwalker as pyg
 
pyg.render(df, spec_path="./gw_config.json", computation="browser")

Use to_render_html for a static renderer export.

from pygwalker.api.html import to_render_html
 
html = to_render_html(df, spec_path="./gw_config.json", computation="browser")

Migrate older specs

pygwalker.spec.migrate updates a saved PyGWalker or Graphic Walker spec to the current schema shape.

import json
import pygwalker as pyg
 
migrated = pyg.spec.migrate("./old_gw_config.json")
 
with open("./gw_config.json", "w", encoding="utf-8") as f:
    json.dump(migrated, f, ensure_ascii=False, indent=2)

Signature:

pygwalker.spec.migrate(spec, *, version=None) -> dict

spec can be:

InputAccepted
Loaded Python objectdict or list
JSON stringYes
Existing local file pathYes

If a string looks like invalid JSON or the file path does not exist, migrate raises ValueError.

Common traps

TrapFix
Passing a local file through spec in new codeUse spec_path.
Expecting static HTML to save edits back to spec_pathUse a live notebook/app backend with save support.
Passing spec_path to an adapter that already received a WalkerPut the spec path on the original Walker.
Migrating a remote spec URL with spec.migrateLoad the spec object first, then pass the object or JSON string.

Related Guides