Giter Site home page Giter Site logo

notion-to-obsidian-converter's Introduction

Note: I'm unfortunately very tied up with work at this time, but feel free to open issues with any requests, suggestions, questions, or bugs! I'll try to address them as soon as life settles down again. Pull requests are welcome!

Thank you! <3

Notion to Obsidian Converter

This is a simple script to convert exported Notion notes to Obsidian (or maybe other systems too).

Usage

  1. Download Notion data from Notion>Settings & Members>Settings>Export content>Export all workspace content
  2. Unzip the data using 7-Zip (or something better than Window's default)
  3. Get the script
  4. Run node main
  5. Input the path where your Notion notes are
  6. Move notes folder into Obsidian directory

Warning: Notion pages that contain parentheses or dashes in the title will have them removed by Notion while exporting your data so the file will be created without them, even though the link itself will still retain them.

node main.js [args] [path_to_export]

node main.js /my/notion/export

node main.js my_export

node main.js -v[vv] my_export

node main.js --help

How it works

Paths:

The script searches through every path and removes the long uuid at the end of both the directory paths and the file paths.

Conversion Features:

  • Markdown links are converted from [Link Text](Notion\Link\Path) to [[Link Text]]. It isn't perfect due to name collision, but it works for most links. Some links contain www.notion.so when they are related table records and those are converted from https://www.notion.so/The-Page-Title-2d41ab7b61d14cec885357ab17d48536 to [[The Page Title]].

  • CSV links are converted from ../Relative%20Path/To/Page%20Title.md to [[Page Title]]. Again, not perfect but it works for most links.

  • After CSV's have their links corrected a secondary Markdown file is created with the same name and all of its contents converted into a Markdown table.

  • URL links found in Markdown are left as-is: [Link Text](URL) because Obsidian renders these correctly. The signifier for a "valid URL" is just containing :// or if it matches a standard IP address structure, so it captures http://, https:// and other networks like ipfs:// as well as xxx.xxx.xxx.xxx.

  • If a link contains illegal characters *"/\<>:|? the character is replaced with a space.

  • Image links are converted from ![Page%20Title%20c5ae5f01ba5d4fb9a94d13d99397100c/Image%20Name.png](Page%20Title%20c5ae5f01ba5d4fb9a94d13d99397100c/Image%20Name.png) to ![Page Title/Image Name.png]

Why

Windows can't handle large paths. After unzipping the Notion data I wasn't able to move the folder because Windows doesn't like long paths and Notion put a long uuid on every directory and file.

Note

This is not made to be robust. Don't run it twice on the same export or it's likely to fail and truncate paths unnecessarily.

Contributors

notion-to-obsidian-converter's People

Contributors

codemysky avatar connertennery avatar nguyentran0212 avatar zeyus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notion-to-obsidian-converter's Issues

Images aren't linked

Images are exported in a folder that share's the page's title and are named "Untitled.png" and probably "Untitled-1.png" etc.

Notion Table Relations

Notion tables have relational properties that allow connections to records of the same table or records of another table. When exported it has the format:
Events: ../Events%202e94ae45e5a748078004f261e2ef5504/A%20Letter%20Delivered%2030c4fe04a118409ea8563041a7a70fb2.md, ../Events%202e94ae45e5a748078004f261e2ef5504/Meeting%20the%20Recruiter%209cfd8aa5a7c849a7a45185df8e9c8569.md, ../Events%202e94ae45e5a748078004f261e2ef5504/Intro%20to%20Gilead%203aced493f7d74fac959b9ead301f449a.md
or
PropertyName: relativePath, relativePath, relativePath

Need to convert all of those relative paths to actual links.

Attachments in Obsidian

I'm new to the whole Obsidian world, and something that I have not fully understood is the concept of attachments and attachment folder.

When I use your cli to convert my Notion files to Obsidian, it will create a folder hierarchy in which the .md file is accompanied with an attachment folder (with the same name) which contains images OR it might be Level 2 notes and their attachment and so on. Let me give an actual example

Here in my notion I have a Work folder which contains two sub folders

  • AWS Key which is a page
  • CircleCI which is a folder containing two pages

image

Running this repo cli will result in
image

At first glance I see that each page has a sibilling attachment folder (if it contains images etc.), but dragging and dropping them in the Obsidian vault will result in weird hierarchy

image

which is a mix of attachment and pages.

Do you have any comment on this issue and how do you imagine someone using your cli for converting nested pages (folders) from notion?

Does it makes sense for the cli to accept an option like aggregate attachments into a single folder in the root and all pages' links gets updated accordingly? This way the nested folder in Obsidian would be only for pages (and not attachments).

CSV to Markdown Table

Right now .csv files have their links updated but nothing else is changed. Obsidian doesn't open them so they need to be converted into Markdown tables.

An issue with Notion's exporting is that any data table type is exported as .csv and as folders with each file inside being a record in that table. These need to be turned into Markdown tables with a new page created for them to house the table since there's no corresponding exported page, just a .csv and a folder.

e.g.

Kanban:

Title

not started in-progress done
task 1 task 2 task 3

becomes:

Title.csv
Title(folder)
  |-task 1
  |-task 2
  -task 3

Add option for logging output to user

#21 Shows that users can't see what's actually happening while the script is running.

Add an option to show logging while the script runs so users can verify that it's actually working and see what it's doing.

Invalid path error

Sorry to pester you again :)
I am getting the following error.

PS C:\Users\ DummyMe\Desktop\New folder> node main
Notion Export Path:
A
readline.js:1147
            throw err;
            ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at Object.readdirSync (fs.js:950:10)
    at fixNotionExport (C:\Users\ DummyMe\Desktop\New folder\main.js:200:28)
    at C:\Users\ DummyMe\Desktop\New folder\main.js:239:17
    at Array.forEach (<anonymous>)
    at fixNotionExport (C:\Users\ DummyMe\Desktop\New folder\main.js:238:14)
    at C:\Users\ DummyMe\Desktop\New folder\main.js:11:17
    at Interface._onLine (readline.js:327:5)
    at Interface._line (readline.js:658:8)
    at Interface._ttyWrite (readline.js:1003:14)
    at ReadStream.onkeypress (readline.js:205:10) {
  code: 'ERR_INVALID_ARG_TYPE'
}

PS. I ran the old main.js it worked fine (not the table linking, but ran)
image

Originally posted by @dummifiedme in #11 (comment)

Cannot find module 'readline/promises'

Hello!

Thank you for creating this script, it will help me with my database relocation from Notion to Obsidian.

Not sure what is happening but I am getting the following message:

Error: Cannot find module 'readline/promises'
Require stack:
- C:\Notion-to-Obsidian-Converter-main\main.js
←[90m    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)←[39m
←[90m    at Function.Module._load (node:internal/modules/cjs/loader:778:27)←[39m
←[90m    at Module.require (node:internal/modules/cjs/loader:1005:19)←[39m
←[90m    at require (node:internal/modules/cjs/helpers:102:18)←[39m
    at Object.<anonymous> (C:\Notion-to-Obsidian-Converter-main\main.js:2:18)
←[90m    at Module._compile (node:internal/modules/cjs/loader:1103:14)←[39m
←[90m    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)←[39m
←[90m    at Module.load (node:internal/modules/cjs/loader:981:32)←[39m
←[90m    at Function.Module._load (node:internal/modules/cjs/loader:822:12)←[39m
←[90m    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)←[39m {
  code: ←[32m'MODULE_NOT_FOUND'←[39m,
  requireStack: [ ←[32m'C:\\Notion-to-Obsidian-Converter-main\\main.js'←[39m ]
}

Can you please help?

Thanks!
Leo

Provide npm package.

It would be conveniont if users could run npx notion-to-obsidian in their content directory.

Extra lines in the markdown

Can there be a way to remove the extra lines that notion exports generate? There is one extra new line after each sentence.

Forexample:

A header line

  1. Content line one which is like one block.
  2. This is a second line and there shouldn't be any space/newline between these two lines.
    • But notion exporter creates one linebreak after each line (block).

Notion Exported Markdown looks like::

A header line

  1. Content line one which is like one block.

  2. This is a second line and there shouldn't be any space/newline between these two lines.

    • But notion exporter creates one linebreak after each line (block).
  • Can we please fix it with this code while the conversion?
    • it might look for blank lines and remove them. If there are more than one blank lines, it removes only one. Then, I think the whole thing will be neat! :)
      I can only request, I don't know much coding, but notion to obsidian converter can be my resort to capture content across decives and put it in Obsidian at the end of the day or the week.

And, as I had expressed earlier, THANKS for this tool!

Image Re-link not working

I used this to exported notion files, with image styled with(I've not edit anything after exporting from notion)

![Untitled](Perceiver%20IO%20A%20General%20Architecture%20for%20Structured%206d4d05e8eeef470f9a3148f92e0250b2/Untitled.png)

but these are converted to ![[Untitled]] and this seems not working well.
I'm using Windows 11.
Is there anybody treating this issue?

The databases lose the linking

The database after conversion is shown as a markdown table, but the "link" is gone. Is it something which is difficult to get done or maybe skipped while programmming?

I am very thankful to you for this code btw 👍
Just noticed this and thought I should post.

Implementation into Obsidian's Importer plugin

Hi @connertennery! Recently, the Obsidian team has started work on an official plugin called 'Importer', for importing notes from other applications, one of the proposed formats is Notion.

Since you've worked on this script and have extensive knowledge on how the syntax should be properly converted, I was wondering if you're interested in implementing the convertion logic into the plugin. There is a bounty attached to succesfully implementing the code within the provided timeframe (10 days) after assignment.

I've already applied for the assignment, but I'll withdraw it if you're interested in working on it.
Someone has already gotten assigned to the converter, see the issue mentioned above.

LinkText should be decoded always

Pages' links are in languages that are written in non-ascii characters should be decoded in order to appear in the correct way.

For example, a link that is written in Arabic, and should be shown as كتابة 50 تدوينة خلال السنة is shown as %D9%83%D8%AA%D8%A7%D8%A8%D8%A9%2050%20%D8%AA%D8%AF%D9%88%D9%8A%D9%86%D8%A9%20%D8%AE%D9%84%D8%A7%D9%84%20%D8%A7%D9%84%D8%B3%D9%86%D8%A9.

This can be fixed easily be using decodeURI JavaScript's method.

Thank you so much :)

Hello Conner and contributors - thank you so much! I hope you'll forgive me for clogging the system with another issue, it's just the simplest way I found to drop a word of gratitude for you having taken the time to build it and share it with the world. It worked like a charm. Thank yoU!

Fix Notion-specific links

I don't know why these are sometimes used, but occasionally there are links that go to specific pages using a Notion URL. e.g. https://www.notion.so/This-is-the-page-title-a7cf21e77e6d411c9d76fa9386e405f6
Seems like they're part of the related records properties.

Characters "omd" are converted to "[[]]"

The string omd is converted into [[]]. In some languages, this string is used in normal words. For example, in my language the word "omdat" is converted into "[[]]at".

I fixed this by replacing the characters omd into 1o2m3d in my original export, let main.js do its work, and replace 1o2m3d into omd afterwards.

[github]: missing topics

This repository doesn't have topics such as notion, obsidian, obsidian-md, markdown-converter which causes less reach. Please add these topics, so Obsidian users can easily find this great repository! 😊

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.