Comments on Google Docs,
where you actually work.
Margin captures Google Docs comments and suggestions into a project workspace you actually own. Local-first, open source, no vendor lock-in.
What it does.
Margin subscribes to a Google Doc and pulls every comment, suggestion, and reply into a project you own. Versions are immutable snapshots. Comments stay anchored to text, even after edits.
The browser extension watches the docs you have open and quietly sends comment activity to your backend. The CLI and API let you create projects, cut versions, replay comments onto a new draft, and stage edits as Suggested Edits without touching your originals.
Designed for the working writer who does the work in Google Docs but needs a system of record that doesn't trap your data.
Install.
One backend, one extension. The extension talks to your own backend over an opaque API token, never to a third party.
Backend:
$ bunx --bun create margin@latestExtension:
$ open https://chromewebstore.google.com/detail/marginConnect your Google account.
Margin only ever sees docs you explicitly open with the add-on, create from Margin, or pick from Drive. drive.file scope only.
$ bun margin connect → open https://accounts.google.com/o/oauth2/v2/auth?... ✓ token stored for vinay@hiremath.net
Track a doc.
Click the extension, hit Add to Margin, pick a project. The doc becomes a v1: a frozen copy you can replay comments onto.
The picker runs sandboxed inside the extension popup. The popup posts
the picked file id to the backend, which copies the doc, computes a
content hash, and subscribes to a Drive files.watch push
channel. From here on, every comment edit shows up in your project.
Capture replies and suggestions.
Suggestion threads in Google Docs are not exposed via API. Margin scrapes them from the rendered sidebar, deduplicates, and POSTs them to your backend.
$ bun margin comments tail --project alpha [14:02:11] v3 · Sandra → "I'd cut the second paragraph." (suggestion) [14:02:34] v3 · Mike → reply on §2.1 thread [14:03:01] v3 · Sandra → resolved §1.4 thread
Projects, versions, overlays.
A project owns a doc. A version is an immutable snapshot. An overlay is a planned set of edits you apply as Suggested Edits on a derivative copy.
The point: your originals stay clean. Suggestions land on a derivative copy that the original author can accept, reject, or ignore. Comments re-anchor automatically across versions using paragraph-hash plus structural offset, with confidence scoring for the cases where the text moved.
Privacy by default.
Margin runs on your infrastructure. No analytics, no telemetry, no third-party calls.
Refresh tokens are envelope-encrypted with a per-row data key wrapped
by your master key. API tokens are mgn_ opaque strings
stored as sha256 hashes. The extension only ever talks to the backend
URL you configure.
Open source.
MIT licensed. Self-host or run the hosted instance: same code, same data model.
Source on GitHub. Issues, pull requests, and weird ideas welcome.
FAQ.
Why not a comments-style API? Workspace's public API can read anchored comments but cannot author them, and it doesn't expose suggestion-thread replies at all. Margin reads through the API where it can and scrapes the rendered sidebar where it has to.
Does this work for non-Docs files? Not yet. Slides and Sheets are on the roadmap once the comment-anchoring model stabilizes for body text.
Can I host this myself? Yes. There's a Dockerfile and a Fly.io deploy template. SQLite + Bun, single machine is fine for a team.