OneNote to Markdown — VS Code extension
Export OneNote notebooks to a Markdown file tree directly from VS Code:
a sidebar tree of notebooks → section groups → sections with checkboxes,
device-code sign-in, and export commands with progress, dry-run, conflict
policy and export history. The Markdown layout is identical to the companion
CLI (onenote-convert-to-md).
What you get
- Sidebar view "OneNote → Notebooks": notebooks, section groups,
sections (checkboxes, persisted) and pages. Title-bar buttons:
Export (⇪), Dry run (👁), Filter pages (🔍), Sign in (🔑),
Refresh (⟳). Right-click a notebook/section for Export this… /
Dry run this….
- Export: pages →
<out>/<notebook>/<section>/<page>.md (section
groups nest as folders; a page with subpages becomes a folder with a
same-named .md inside), images in _images/, file attachments in
_attachments/ (hoisted under ## Attachments), YAML frontmatter per
page (title, created, modified, tags), internal OneNote page links
rewritten (relative .md links or [[wikilinks]]), highlights as
==text== or colored <mark>, callout boxes as > [!NOTE].
- Dry run: writes nothing — opens a read-only document listing every
page/image/attachment with its target path plus the diff vs. the previous
export.
- Safe re-runs: each export writes
.onenote-export.json (sha1 per
output file) into the notebook folder; the next run reports
N added, N changed, N unchanged, N removed in the "OneNote Export"
output channel. Existing files are kept by default (skip); overwrite
rewrites (hand-added YAML properties survive), rename writes
<name>-2.md next to them.
- Reliability: Graph calls retry on 429/5xx with backoff; a failed page
is skipped with a warning and counted, not aborting the export. Long runs
show progress and are cancellable.
Prerequisites: Microsoft Entra app registration (≈5 min, free)
- Go to https://entra.microsoft.com → Microsoft Entra ID → App
registrations → New registration; name it e.g.
onenote-convert-to-md.
- Supported account types: Personal Microsoft accounts only (or any
directory + personal). Redirect URI (recommended): platform Mobile and
desktop applications, URI
http://localhost.
- Open the registration → Authentication → Advanced settings →
Allow public client flows = Yes → Save.
- API permissions → Add → Microsoft Graph → Delegated
permissions → add
Notes.Read.
- Copy the Application (client) ID from the Overview page — you will
paste it into the
onenoteConvert.clientId setting.
Install
- From a
.vsix: Extensions view → … → Install from VSIX…, or
codium --install-extension onenote-convert-to-md-<version>.vsix, then
reload the window.
- From source (development): clone the repository, open the
vscode-extension/ folder as the workspace, npm install, press F5
(a pre-launch task builds the bundle; under Flatpak VSCodium the task
falls back to the host Node via /run/host — if that fails, build from a
host terminal with npm run watch).
First run
- Set
onenoteConvert.clientId in Settings (or launch with
ONENOTE_CLIENT_ID=<id> in the environment).
- Click the OneNote icon in the activity bar → the Notebooks view.
If empty, press the Refresh (⟳) title-bar button.
- Sign in (🔑 button or command "OneNote: Sign in"). With a valid
cached token (
~/.onenote-convert-to-md/token.json, shared with the
CLI) it signs in instantly; otherwise a notification shows the device
code (also on the clipboard) with an "Open sign-in page" button — under
Flatpak that button can fail silently, so open
https://microsoft.com/devicelogin manually and enter the code. The
status bar switches to "✓ OneNote".
Everyday use
- Expand a notebook and check the sections to export — or check the
notebook to export all of it. Use Filter pages (🔍) to narrow the
page list by title. Selections persist across restarts.
- Dry run (👁) first if you like: read-only manifest + diff, nothing
written.
- Export (⇪): pick the output folder (prefilled from
onenoteConvert.defaultOutDir when set). If onenoteConvert.onConflict
is empty you are asked what to do with existing files. Progress shows as
a notification; the full log — including the per-run history diff — is in
the "OneNote Export" output channel. At the end you can reveal the
output folder in the Explorer.
Settings
| Setting |
Default |
Meaning |
onenoteConvert.clientId |
"" |
Entra app registration client id (falls back to ONENOTE_CLIENT_ID) |
onenoteConvert.linkStyle |
relative |
internal page links → relative .md links or [[wikilinks]] |
onenoteConvert.highlightStyle |
mark |
highlights as ==text== or <mark> keeping the color |
onenoteConvert.frontmatter |
true |
YAML frontmatter per page |
onenoteConvert.onConflict |
"" |
existing-file policy skip/overwrite/rename; empty = ask per run |
onenoteConvert.defaultOutDir |
"" |
prefills the output-folder picker (~ expanded) |
The companion CLI (npm start -- … in the repository root) supports the
same options via flags and a .onenote-convert-md.json settings file —
see the repository's docs/usage.md and docs/settings.md.
Troubleshooting
- Activation errors: Help → Toggle Developer Tools (console); Graph
errors/retries: the "OneNote Export" output channel.
Missing client id → set onenoteConvert.clientId or ONENOTE_CLIENT_ID.
AADSTS50011 redirect URI → add http://localhost (mobile/desktop) to
the app registration. AADSTS700016 → wrong client id/tenant.
403 Insufficient privileges → grant consent for Notes.Read on first
sign-in.
- Expired token → delete
~/.onenote-convert-to-md/token.json and sign in
again.
- Flatpak VSCodium: grant network (
flatpak override --user --share=network org.vscodium.codium) if Graph calls fail; host filesystem access
(--filesystem=host) is needed only for the in-app build task fallback.
- "Failed to register Continue config.yaml schema …
yaml.schemas is not a
registered configuration" — comes from the Continue extension, not this
one; install the YAML extension (redhat.vscode-yaml) or ignore.
Repository
https://github.com/JadeWolfII/onenote-convert-to-md — source, CLI,
full docs (docs/), tests.
| |