User data import and export
User data portability lets an authenticated person move subscriptions, watch history, preferences, and playlists into or out of Invidious. The main account package uses JSON. Subscription-only exports also use OPML so other feed tools can consume them.
Portability surface
The data control page is the browser entry point for imports and exports. It accepts files from Invidious, YouTube, FreeTube, and NewPipe, while the authenticated API provides the complete Invidious package as JSON. See Accounts, sessions, and preferences for the account and session context, and Playlists and personal library for the library experience.
The portable account state has clear boundaries:
| Data | Export form | Import sources |
|---|---|---|
| Subscriptions | Invidious JSON or OPML | Invidious JSON, YouTube OPML/JSON/CSV, FreeTube, NewPipe |
| Watch history | Invidious JSON | Invidious JSON, YouTube JSON, NewPipe ZIP |
| Preferences | Invidious JSON | Invidious JSON |
| Playlists and video IDs | Invidious JSON | Invidious JSON or YouTube playlist CSV |
| Passwords, sessions, and account identity | Not included | Not imported |
Export formats
Exports produce data that can be restored in Invidious or used by a compatible feed reader. The export path reads the current user state and returns it without account credentials.
Invidious JSON package
The Invidious JSON package is the full portable account format. It contains subscriptions, watch_history, preferences, and playlists; each playlist contains a title, description, privacy value, and an ordered list of video IDs. The browser download is available from the data control page, and the authenticated API exposes the same package at /api/v1/auth/export/invidious.
Playlist descriptions are exported as plain content. The package includes only the video IDs needed to rebuild the playlist, not a second copy of each video's metadata.
References: src/…/exports.cr• L5-33 src/…/data_control.ecr• L53-65 src/…/authenticated.cr• L34-39
Subscription OPML feeds
OPML is an XML feed-list format used for subscription-only transfer. A normal OPML export points to the Invidious channel feeds. The NewPipe and FreeTube variant points to YouTube channel feeds so those clients can discover the subscriptions.
The subscription manager creates the OPML download when action_takeout=1 is selected. This format does not carry watch history, preferences, or playlists.
References: src/…/subscriptions.cr• L72-117 src/…/data_control.ecr• L55-61
Import workflows
Imports start from an authenticated data control request or an authenticated API request. Each source parser converts its input into account state, then saves the affected part of the user record.
The following diagram shows how the browser and API entry points route portable data into the account state.
flowchart LR
A[Data control page] --> B[File type and source]
C[Authenticated API] --> D[Invidious JSON]
B --> E[Source parser]
D --> E
E --> F[Subscriptions]
E --> G[Watch history]
E --> H[Preferences]
E --> I[Playlists]
F --> J[Saved user state]
G --> J
H --> J
I --> J
Invidious account import
An Invidious JSON import restores the portable account package. Subscriptions and watch history merge with the current values. Preferences replace the current preference set. Each valid playlist becomes a playlist owned by the receiving account.
The browser accepts the package as a file under the Invidious import control. The API accepts the JSON body at /api/v1/auth/import/invidious. The import does not move the source account's password, sessions, or identity.
References: src/…/preferences.cr• L305-370 src/…/imports.cr• L87-153 src/…/authenticated.cr• L41-55
YouTube subscription import
YouTube subscription exports are accepted as OPML, JSON, or CSV. The importer extracts channel IDs, removes duplicates, and refreshes the subscription set so the account can use the channels in its feed.
The CSV reader uses the first column for the channel ID. This avoids dependence on localized column names in a YouTube export. The reader processes at most 1,200 rows.
References: src/…/imports.cr• L7-31 src/…/imports.cr• L160-200 src/…/data_control.ecr• L15-22
YouTube playlist and history import
YouTube playlist CSV files create a new private playlist. The file name supplies the playlist name. Each usable video ID is looked up before it is added, so unavailable videos do not block the other entries.
YouTube watch history imports use JSON. The importer reads video IDs from history links and joins them to the existing history without duplicate entries. The data control page presents these as separate upload choices because the two exports have different formats.
References: src/…/imports.cr• L33-81 src/…/imports.cr• L202-237 src/…/data_control.ecr• L24-32
FreeTube and NewPipe imports
FreeTube and NewPipe imports support subscription transfer from other privacy-focused clients. NewPipe accepts a subscription JSON file or a ZIP archive with its data. The archive can also provide watch history.
NewPipe channel URLs are resolved to channel IDs when needed. The imported values then follow the same duplicate removal and subscription refresh path as other subscription imports. The ZIP input is size-limited and must contain the expected NewPipe data file.
References: src/…/imports.cr• L239-329 src/…/data_control.ecr• L34-47
Merge and restore behavior
Import behavior depends on the kind of state. This distinction lets a person add data from another source without losing existing subscriptions or history, while still making a preference restore act as a complete preference choice.
| State | Restore behavior | Result |
|---|---|---|
| Subscriptions | Merge | Existing and imported channels are combined without duplicates. |
| Watch history | Merge | Existing and imported video IDs are combined without duplicates. |
| Preferences | Replace | The imported preference object becomes the user's preference set. |
| Playlists | Create | Imported playlists are created for the receiving user. |
Imported playlist videos are rebuilt from current video data. A video that cannot be fetched is skipped. An imported Invidious playlist keeps its title, description, and privacy value, while a YouTube playlist starts as private.
References: src/…/imports.cr• L88-153 src/…/imports.cr• L34-80
Preference compatibility
Preferences are JSON-serializable account settings rather than a fixed list of raw form values. The preference model supplies defaults for missing fields and converts older representations such as boolean theme values. It also bounds selected numeric settings and limits user-facing strings during parsing.
This makes an exported preference object portable across supported versions, but it does not make arbitrary JSON a valid preference set. The authenticated preference API uses the same preference format as the full Invidious package.
References: src/…/preferences.cr• L1-60 src/…/preferences.cr• L62-123 src/…/authenticated.cr• L14-32
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the fields produced by
User::Export.to_invidiousaligned with the fields accepted byUser::Import.from_invidious. - Keep browser upload names and accepted source formats aligned between
data_control.ecrandupdate_data_control. - Keep OPML feed URLs compatible with both the normal Invidious export and the NewPipe/FreeTube export variant.
- Keep preference conversion rules compatible with both full account imports and the authenticated preference API.
- Keep playlist privacy and video-count rules aligned between exported playlist data and playlist import behavior.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Unsupported subscription, playlist, or history file type | The browser import stops with HTTP 415 and an invalid-file message. | Select the source-specific format shown on the data control page. |
| YouTube CSV has more than 1,200 subscription rows | Rows after the limit are not imported. | Split a larger subscription export before upload. |
NewPipe ZIP lacks newpipe.db or exceeds the input size limit | The import is rejected. | Upload the NewPipe data ZIP with its expected database file. |
| Imported video cannot be retrieved | That video is skipped while the rest of the playlist or history can continue. | Review the restored playlist or history after import. |
| Imported playlist exceeds the configured playlist length | The Invidious JSON import raises an import error for that playlist. | Keep playlist exports within the instance playlist limit. |
| Invidious JSON omits a required playlist field | The affected playlist is skipped. | Preserve title, description, privacy, and videos in the package. |
Key files
| File | Why to read it |
|---|---|
src/invidious/user/exports.cr | Defines the portable Invidious JSON package and its playlist shape. |
src/invidious/user/imports.cr | Defines source formats, merge behavior, and restore rules. |
src/invidious/routes/preferences.cr | Connects the browser data control workflow to each import type. |
src/invidious/views/user/data_control.ecr | Shows the user-facing import choices and export links. |
src/invidious/routes/subscriptions.cr | Defines subscription downloads in JSON and OPML. |
src/invidious/routes/api/v1/authenticated.cr | Exposes authenticated preference and full account portability endpoints. |
src/invidious/user/preferences.cr | Defines the portable preference shape and compatibility rules. |