# JSON Project Import And Export
URL: https://pro.rv-grid.com/guides/gantt/features/json-project-import-export/
Source: src/content/docs/guides/gantt/features/json-project-import-export.mdx
Description: Serialize, clone, parse, and lightly validate complete Gantt project snapshots.
JSON project import/export provides a framework-neutral way to move complete Gantt project snapshots between files, APIs, tests, undo buffers, and server-side workflows. The helpers operate on `ProjectSnapshot` data only. They do not depend on the grid, DOM, or framework wrappers.

Import the helpers from Enterprise:

```ts
import {
  cloneProjectSnapshot,
  createJsonSnapshotRecipe,
  exportProjectSnapshot,
  parseProjectSnapshotJson,
} from '@revolist/revogrid-enterprise';
```

## Export A Snapshot

Use `exportProjectSnapshot()` to serialize the current project snapshot.

```ts
const json = exportProjectSnapshot(project, { space: 2 });
```

The optional `space` value is passed to `JSON.stringify`, so you can use it for readable file exports.

## Import A Snapshot

Use `parseProjectSnapshotJson()` to parse JSON into a typed result instead of throwing for common invalid payloads.

```ts
const parsed = parseProjectSnapshotJson(json);

if (!parsed.ok) {
  showImportError(parsed.error);
  return;
}

applyProject(parsed.project);
```

The parser checks the top-level project shape:

- Required string fields: `id`, `name`, `version`, `currency`, `timeZone`, `primaryCalendarId`, and `updatedAt`.
- Required array fields: `tasks`, `dependencies`, `resources`, `assignments`, `calendars`, and `baselines`.

It intentionally performs lightweight validation. Run scheduler validation or your application-specific validation after import when you need deeper checks for dates, task references, dependency cycles, resource assignments, or business rules.

## Clone Before Editing

Use `cloneProjectSnapshot()` when you need a JSON-safe deep copy before staging edits.

```ts
const draft = cloneProjectSnapshot(project);
draft.name = 'Scenario copy';
```

The clone is detached from nested task, dependency, resource, assignment, calendar, and baseline arrays.

## File Picker Recipe

For host applications that own file pickers and save dialogs, use `createJsonSnapshotRecipe()` with injected text readers and writers.

```ts
const recipe = createJsonSnapshotRecipe({
  readText: () => selectedFile.text(),
  writeText: (fileName, contents) => downloadTextFile(fileName, contents),
  fileName: (project) => `${project.id}-snapshot.json`,
});

const imported = await recipe.load();
await recipe.save(project, 2);
```

The recipe throws an `Error` when load/save hooks are missing or the imported JSON fails parsing. Use the lower-level parser directly when you prefer result objects over exceptions.

## What The JSON Contains

The exported JSON is the project snapshot, not rendered grid state. It includes project metadata and entity arrays:

- Tasks
- Dependencies
- Resources
- Assignments
- Calendars
- Baselines

It does not include projected Gantt row fields, rendered timeline geometry, current scroll position, expanded row state, active selection, filters, or toolbar state.

## Persistence Adapters

The REST, GraphQL, Supabase, and PostgreSQL examples build on the same JSON snapshot helpers. Use those adapters when the snapshot should be loaded from or saved to an application backend.

See [Integrations And Frameworks](../integrations-and-frameworks/) for adapter examples.
