What is Sync Folds?
Sync Folds is an Obsidian plugin that synchronizes your fold states across all your devices. When you fold or unfold sections in your notes, those states are preserved and synced, ensuring a consistent editing experience wherever you open your vault.The Problem
By default, Obsidian stores fold states inlocalStorage, which is browser-specific storage that doesn’t sync across devices. This means:
- Fold states you create on your desktop don’t appear on your mobile device
- Each device maintains its own separate fold configuration
- You lose your carefully organized document structure when switching devices
localStorage is a web storage API that browsers use to store data locally. Since it’s tied to the specific browser instance, it cannot sync through Obsidian Sync, iCloud, or any other file syncing solution.How Sync Folds Solves This
Sync Folds intercepts fold state changes and stores them in the plugin’sdata.json file, which lives in your vault at .obsidian/plugins/sync-folds/data.json. Since this file is part of your vault, it syncs automatically with:
- Obsidian Sync
- iCloud
- Dropbox
- Git
- Syncthing, CouchDB, or any self-hosted solution
Key Features
Automatic Sync
Fold changes are automatically saved and synced as you work (debounced to 150ms)
Cross-Device Support
Works on both desktop and mobile devices (not desktop-only)
No Network Required
All syncing happens through your existing file sync solution - no external services
Manual Controls
Export and import commands let you manually control fold state sync
How It Works
The plugin operates in three key phases:1. On Plugin Load
When Obsidian starts and the plugin loads:- If fold states exist in
data.json, they’re imported intolocalStorage - If no fold states exist in settings, current
localStoragestates are exported to the file - The plugin begins intercepting
localStoragechanges
2. During Active Use
As you fold and unfold content:- The plugin intercepts calls to
localStorage.setItem()andlocalStorage.removeItem() - Changes are debounced (150ms) to avoid excessive writes
- Updated fold states are saved to
data.json - Your sync solution propagates the changes to other devices
3. When Settings Change Externally
Whendata.json is updated by your sync solution:
- The plugin detects the external change
- It compares previous and current fold states
- Deleted folds are removed from
localStorage - New or updated folds are applied to
localStorage
The plugin maintains a cached copy of fold states to efficiently detect what changed during external updates.
Technical Details
Fold State Data Structure
Fold State Data Structure
Fold states are stored as JSON with this structure:Example:
localStorage Interception
localStorage Interception
The plugin intercepts localStorage by replacing the native The fold prefix is constructed as:
setItem and removeItem methods:{appId}-note-fold-{filePath}Get Started
Installation
Install Sync Folds from Community Plugins or manually
Quickstart Guide
Get up and running in under 5 minutes