Quickstart

From install to first parse.

1. Install

npm install decant-core

2. Extract an AI conversation

import { detectPlatform, isAiChatUrl } from "decant-core";

if (isAiChatUrl(window.location.href)) {
  const { platform, parser } = detectPlatform(window.location.href);
  if (parser && parser.isAvailable(window.location.href)) {
    const result = await parser.parse();
    console.log(result.title);   // conversation title
    console.log(result.model);   // model slug when available
    console.log(result.messages); // [{ role: 'User' | 'Assistant', content, ... }]
  }
}

3. Extract a regular web article

import { extractArticle } from "decant-core";

const article = await extractArticle(document /* or an HTML string */, {
  url: window.location.href,
});

console.log(article.title);
console.log(article.markdown);  // clean, reusable Markdown
console.log(article.engine);    // 'readability' | 'defuddle' | 'raw'

4. Use it outside the browser (Node / CLI)

Article extraction works in Node via linkedom. Detection is pure string/URL logic and runs anywhere.

import { extractArticle } from "decant-core";
import { readFile } from "node:fs/promises";

const html = await readFile("page.html", "utf8");
const article = await extractArticle(html, { url: "https://example.com" });
console.log(article.markdown);

Subpath imports

Pull only what you need — every subpath is tree-shakeable.

// Individual parsers
import { ChatGPTParser } from "decant-core/ai/chatgpt";
import { ClaudeParser } from "decant-core/ai/claude";

// Article extraction
import { ArticleParser } from "decant-core/article";

// Detection
import { detectPlatform, isAiChatUrl, parsers } from "decant-core";

// Markdown utilities
import { convertToMarkdown, normalizeLatexMath } from "decant-core";
Manifest V3 extensions: parsers are DOM-ready and work in content scripts. Register what you need in your content script, then call parse() on the current page. No bundled server, no API keys.