Skip to content

Instantly share code, notes, and snippets.

@dnnsmnstrr
Created March 7, 2026 16:45
Show Gist options
  • Select an option

  • Save dnnsmnstrr/5c4073193c9edb2ecd7c9bb0cad5790e to your computer and use it in GitHub Desktop.

Select an option

Save dnnsmnstrr/5c4073193c9edb2ecd7c9bb0cad5790e to your computer and use it in GitHub Desktop.
Karakeep to Shiori
const fs = require('fs');
const path = require('path');
// Read the JSON file
const bookmarksFilePath = path.join(__dirname, 'bookmarks.json');
const bookmarksData = JSON.parse(fs.readFileSync(bookmarksFilePath, 'utf-8'));
// Function to convert bookmarks to CSV/TSV
function convertToCSV(bookmarks, delimiter = ',') {
const header = ['URL', 'Title'];
const rows = bookmarks.map(bookmark => {
const url = bookmark.content.url || '';
const title = bookmark.title || '';
return `${url}${delimiter}${title}`;
});
return [header.join(delimiter), ...rows].join('\n');
}
// Specify the output file format (CSV or TSV)
const outputFormat = 'csv'; // Change to 'tsv' for TSV format
const delimiter = outputFormat === 'tsv' ? '\t' : ',';
const outputFilePath = path.join(__dirname, `bookmarks.${outputFormat}`);
// Convert bookmarks to CSV/TSV
const csvData = convertToCSV(bookmarksData.bookmarks, delimiter);
// Write to output file
fs.writeFileSync(outputFilePath, csvData, 'utf-8');
console.log(`Bookmarks exported to ${outputFilePath}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment