Skip to main content

ImportedDataState

Data structure for importing Excalidraw scenes. All fields are optional to allow partial imports.
string
Type identifier for the data format
number
Version number of the data format
string
Source application or identifier
readonly ExcalidrawElement[] | null
Array of elements to import, or null
Partial<AppState> | null
Partial application state to import. Can include legacy AppState properties:
  • isSidebarDocked (deprecated) maps to defaultSidebarDockedPreference
boolean
Whether to scroll to the imported content after loading
LibraryItems_anyVersion
Library items to import (supports v1 and v2 formats)
BinaryFiles
Binary files (images, etc.) associated with the elements

ExportedDataState

Data structure for exporting Excalidraw scenes. This is a stricter version of ImportedDataState with required fields.
string
required
Type identifier, typically "excalidraw"
number
required
Version number of the Excalidraw format
string
required
Source application identifier
readonly ExcalidrawElement[]
required
Array of all elements in the scene
ReturnType<typeof cleanAppStateForExport>
required
Cleaned application state with only exportable properties
BinaryFiles | undefined
required
Binary files associated with the scene, or undefined if none

BinaryFileData

Represents a binary file (typically an image) in Excalidraw.
ValueOf<typeof IMAGE_MIME_TYPES> | typeof MIME_TYPES.binary
required
MIME type of the file. Can be an image type or generic binary
FileId
required
Unique identifier for the file (branded string type)
DataURL
required
Data URL containing the file contents (branded string type)
number
required
Epoch timestamp in milliseconds when the file was created
number
Epoch timestamp in milliseconds when the file was last retrieved from storage. Used to determine whether to delete unused files from storage
number
Version of the file. Used to determine whether the file dataURL has changed (e.g., as part of restore due to schema update)

BinaryFileMetadata

Binary file data without the actual data URL (useful for listing files without loading full data).
string
required
MIME type of the file
FileId
required
File identifier
number
required
Creation timestamp
number
Last retrieved timestamp
number
File version

BinaryFiles

A record mapping element IDs to their associated binary file data.

Library Types

LibraryItem

Represents a reusable component in the library (v2 format).
string
required
Unique identifier for the library item
'published' | 'unpublished'
required
Publication status of the library item
readonly NonDeleted<ExcalidrawElement>[]
required
Array of elements that make up this library item
number
required
Timestamp in epoch milliseconds when the item was created
string
Optional name for the library item
string
Error message if the library item failed to load

LibraryItems

Array of library items (v2 format).

LibraryItem_v1 (Deprecated)

Legacy v1 library item format. Do not use outside of migration paths.

LibraryItems_v1 (Deprecated)

Legacy v1 library items array. Do not use outside of migration paths.

LibraryItems_anyVersion

Union type supporting both v1 and v2 library formats for backward compatibility.

ExportedLibraryData

Data structure for exporting library data.
string
required
Type identifier, typically "excalidrawlib"
typeof VERSIONS.excalidrawLibrary
required
Version number of the library format
string
required
Source application identifier
LibraryItems
required
Array of library items (v2 format)

ImportedLibraryData

Data structure for importing library data. Supports both current and legacy formats.
string
Type identifier
number
Version number
string
Source application identifier
LibraryItems
Library items in v2 format
LibraryItems
Deprecated (v1) - Legacy library format

ExcalidrawLibraryIds

Helper type for tracking library item IDs.
LibraryItem['id'][]
required
Array of library item IDs

SceneData

Data structure for updating the scene, used with the updateScene API method.
ImportedDataState['elements']
Elements to update in the scene
ImportedDataState['appState']
Application state to update
Map<SocketId, Collaborator>
Collaborators to update
CaptureUpdateActionType
Whether to capture this update in history for undo/redo

ExcalidrawInitialDataState

Extended import data state used when initializing Excalidraw.
Inherits all properties from ImportedDataState but allows libraryItems to be a Promise.

Branded Types

These are string types with runtime branding for type safety:

DataURL

String representing a data URL (base64 encoded file data).

FileId

String representing a unique file identifier.

SocketId

String representing a WebSocket connection identifier.

Legacy Types

LegacyAppState

Map of deprecated AppState keys for migration purposes.
[boolean, 'defaultSidebarDockedPreference']
Deprecated #6213 - Maps to defaultSidebarDockedPreference. TODO: remove 23-06-01
The LegacyAppState type is a helper for downstream abstractions during data migration. Do not consume it directly in new code.

Usage Examples

Importing Data

Working with Binary Files

Exporting Data