A TypeScript library that parses and renders AI answers from ChatGPT, Google AI Overview, Google AI Mode, Gemini and Bing AI Mode, as cloro returns them. cloro is the API for AI answers.
Framework-Agnostic: This library returns HTML strings that can be rendered in any framework (React, Vue, Svelte, vanilla JS, etc.).
- 🤖 Multi-Provider Support: ChatGPT, Google AI Overview, Google AI Mode, Gemini and Bing AI Mode. Stored Perplexity, Copilot and Grok responses still render
- 🔍 Auto-Detection: Automatically detects the AI provider from response structure
- 🎨 Built-in Styling: Provider-specific styling
- 🔧 Framework-Agnostic: Pure HTML output for any framework
- 🧹 Script removal: Removes
<script>and<noscript>elements. This is not a full HTML sanitizer. - 📦 TypeScript: Full TypeScript support with comprehensive types
- 🎯 Lightweight: No runtime dependencies for core parsing
npm install @cloro-dev/response-parser
# or
yarn add @cloro-dev/response-parser
# or
pnpm add @cloro-dev/response-parser
This library parses AI responses and returns HTML strings. You can render the HTML in any framework.
Security: The parser removes only
<script>and<noscript>elements. It does not remove event handler attributes (for exampleonerror=) orjavascript:URLs. If the HTML comes from a source that you do not trust, sanitizeparsed.htmlwith a full HTML sanitizer (for example DOMPurify) before you render it.
import { parseAiResponse, detectProvider } from "@cloro-dev/response-parser";
// Auto-detect provider and parse
const response = await fetchAIResponse();
const parsed = parseAiResponse(response);
console.log(parsed.provider); // 'CHATGPT' | 'GEMINI' | etc.
console.log(parsed.html); // HTML with <script> and <noscript> elements removed
console.log(parsed.text); // Plain text version
import { parseAiResponse } from "@cloro-dev/response-parser";
function MyComponent() {
const parsed = parseAiResponse(aiResponse, {
removeLinks: true
});
return (
<div dangerouslySetInnerHTML={{ __html: parsed.html }} />
);
}
<script setup>
import { parseAiResponse } from "@cloro-dev/response-parser";
const parsed = parseAiResponse(aiResponse, {
removeLinks: true
});
</script>
<template>
<div v-html="parsed.html"></div>
</template>
<script>
import { parseAiResponse } from "@cloro-dev/response-parser";
const parsed = parseAiResponse(aiResponse, {
removeLinks: true
});
</script>
<div>{@html parsed.html}</div>
import { parseAiResponse } from "@cloro-dev/response-parser";
const parsed = parseAiResponse(aiResponse, {
removeLinks: true
});
document.getElementById('output').innerHTML = parsed.html;
Parse an AI response with auto-detected provider.
Options:
removeLinks:boolean- Remove all hyperlinks from HTML (default:false)removeHeader:boolean- Remove navigation bar/header (default:false;truefor AI Overview & AI Mode. ChatGPT, Perplexity, Gemini, Copilot, Grok, AI Overview & AI Mode)removeFooter:boolean- Remove follow-up input box/footer (default:false;truefor AI Overview & AI Mode. ChatGPT, Perplexity, Gemini, Copilot, Grok, AI Overview & AI Mode)removeSidebar:boolean- Remove sidebar (default:false, ChatGPT, Gemini, Perplexity, Copilot & AI Mode)removeSources:boolean- Remove sources/references panel (default:false, ChatGPT, Gemini, Perplexity, Copilot & Grok)invertColors:boolean- Invert the colors of the page. A light page becomes dark and a dark page becomes light. Images, videos and other media keep their colors (default:false, all providers)
Note: Cookie/privacy banners are automatically removed for ChatGPT, AI Mode, Copilot, Grok, and Perplexity — no option needed. Sign-in prompts are automatically removed for Gemini and Perplexity.
Returns: ParsedResponse | null
interface ParsedResponse {
provider: AIProvider;
html: string;
text: string;
sources?: Array<{
title: string;
url: string;
snippet?: string;
}>;
}
Detect the AI provider from a response.
Returns: AIProvider | null
type AIProvider =
| 'CHATGPT'
| 'GEMINI'
| 'PERPLEXITY'
| 'COPILOT'
| 'AIOVERVIEW'
| 'AIMODE'
| 'BING_AIMODE'
| 'GROK';
PERPLEXITY, COPILOT and GROK are for stored responses only: cloro discontinued those endpoints. Use BING_AIMODE for Bing's AI answers.
| Provider | Status | Features |
|---|---|---|
| ChatGPT | ✅ | Sidebar, header, footer removal, auto cookie banner hiding |
| Gemini | ✅ | Sidebar, header, footer, sources removal |
| Perplexity | Sidebar, header, footer, sources removal, auto cookie banner hiding | |
| Copilot | Sidebar, header, footer, sources removal, auto cookie banner hiding | |
| AI Overview | ✅ | Header, footer removal, WIZ data extraction |
| AI Mode | ✅ | Sidebar, header, footer removal, auto cookie banner hiding |
| Bing AI Mode | ✅ | Renders the whole answer (from the answer frame's srcdoc); header (reasoning panel) and sources removal |
| Grok | Sources removal, auto cookie banner hiding |
import { parseAiResponse } from "@cloro-dev/response-parser";
const parsed = parseAiResponse(response, {
removeLinks: true, // Removes all <a> tags, keeps text
});
const parsed = parseAiResponse(response, {
removeHeader: true, // Remove top navigation bar
removeFooter: true, // Remove follow-up input box
removeLinks: true, // Remove all hyperlinks
removeSources: true, // Remove sources/references panel
});
The engines return pages in a light or a dark theme. Set invertColors to show a page in the other theme.
const parsed = parseAiResponse(response, {
invertColors: true, // Light page becomes dark, dark page becomes light
});
The parser adds a CSS filter to the <html> element. It does not detect the theme of the page. The option applies to parseAiResponse, parser.parse and parser.parseWithProvider. It does not apply when you call a provider class (for example new ChatGPTProvider().parse()) directly.
import { parseAiResponse, AIProvider } from "@cloro-dev/response-parser";
const parsed = parseAiResponse(response, {
provider: "CHATGPT",
});
import { detectProvider } from "@cloro-dev/response-parser";
const provider = detectProvider(response);
console.log(`Detected: ${provider}`); // 'CHATGPT' | 'GEMINI' | etc.
If you were using React components from v0.1.x, here's how to migrate:
import { ResponseRenderer } from "@cloro-dev/response-parser/react";
<ResponseRenderer
response={response}
removeLinks={true}
onProviderDetected={(provider) => console.log("Detected:", provider)}
/>
import { parseAiResponse } from "@cloro-dev/response-parser";
const parsed = parseAiResponse(response, {
removeLinks: true
});
console.log("Detected:", parsed.provider);
<div dangerouslySetInnerHTML={{ __html: parsed.html }} />
The core parsing logic is identical - you just need to handle the HTML rendering yourself in your framework of choice.
- ✅ Added
invertColorsoption for all providers. It inverts the colors of the page, and images and videos keep their colors.metadata.colorsInvertedistruewhen the option is applied - ✅ Fixed The ChatGPT mobile web page showed its answer text dark on a dark background when the viewer's browser is in dark mode. The parser now keeps pages that use Lightning CSS color variables in their light theme
- First release from the Publish workflow, with npm Trusted Publishing and provenance. No library changes
- ✅ Fixed The README said that the parser sanitizes HTML. It removes only
<script>and<noscript>elements. A new Security note tells you to sanitize untrusted HTML before you render it - ✅ Fixed The
package.jsonrepository URL now points tocloro-dev/response-parser
- ✅ Fixed ChatGPT
removeSourcesnow hides the open sources dialog of the mobile page
- ✅ Fixed
require("@cloro-dev/response-parser")failed withexports is not defined. The CommonJS build is nowdist/index.cjs - ✅ Fixed Perplexity
removeSourcesnow hides the open "Sources" popover - ✅ Fixed Perplexity cookie banner (new markup) and sign-in prompts are now always hidden
- ✅ Fixed Copilot
removeHeaderandremoveSidebarno longer break the page layout.removeSidebarno longer hides the references panel - ✅ Fixed Copilot
removeHeadernow hides the date divider - ✅ Fixed ChatGPT
removeSourcesnow hides the sources flyout and the sources sheet on all pages - ✅ Fixed ChatGPT
removeFooterandremoveSidebarno longer change the page structure - ✅ Fixed Gemini sign-in prompt is now always hidden
- ✅ Fixed AI Overview
removeFooternow hides the Google footer - ✅ Fixed Provider detection no longer depends on pattern order for Gemini pages, and no longer reports a Google result page that links to Gemini as Gemini
- ✅ Added Perplexity
removeSidebarsupport (left navigation removal) - ✅ Fixed Perplexity layout rendering in iframes (CSS overrides for single-column flow)
- ✅ Fixed Perplexity
removeFooternow hides the "Ask a follow-up" bar via CSS - ✅ Fixed ChatGPT
removeFooternow hides the composer input form and collapses blank space - ✅ Fixed ChatGPT
removeSidebarnow hides leftover sidebar items via CSS - ✅ Fixed AI Mode
removeHeadernow hides the "New thread" compose button - ✅ Fixed Copilot
removeHeadernow hides the sticky header (share button) - ✅ Improved CSS overrides are now conditional — only injected when the corresponding
remove*option is true (Perplexity, ChatGPT, Copilot)
- ✅ Added ChatGPT automatic cookie banner removal
- ✅ Fixed Copilot sources removal regex to handle variable panel widths
- ✅ Added Copilot
removeSourcesandremoveSidebarsupport - ✅ Added Copilot automatic cookie banner removal
- ✅ Added AI Mode
removeSidebarsupport (history panel removal) - ✅ Fixed AI Mode sidebar/footer removal and detection
- ✅ Added AI Mode automatic cookie consent banner hiding
- ✅ Added
removeSourcesoption for Gemini, Perplexity, and Grok - ✅ Added automatic cookie/privacy banner removal for Perplexity and Grok
- ✅ Fixed Perplexity collapsed answer container (JS animation height workaround)
- ✅ Added Grok provider support
- ✅ Simplified codebase and removed colour inversion
- ✅ Removed React components and hooks (now framework-agnostic)
- ✅ Removed React peer dependency
- ✅ Simplified API to return pure HTML strings
- ✅ Keep core parsing logic (unchanged)
- ✅ Renamed
removeNavbar→removeHeader(removes navigation bar/header) - ✅ Renamed
removeFollowup→removeFooter(removes follow-up input box/footer) - ✅ Extended
removeHeadersupport to AI Overview and AI Mode - ✅ Extended
removeFootersupport to all providers (ChatGPT, Perplexity, Gemini, Copilot, AI Overview, AI Mode) - ✅ Improved ChatGPT styling
- ✅ Updated AI Mode and AI Overview parsers
- ✅ Always removes
<script>and<noscript>elements from the HTML - ✅ Always includes provider-specific styles
- ✅ Always uses provider's base URL for relative links
- ❌ Removed
themeoption (styles are provider-specific) - ❌ Removed
sanitizeoption (always enabled) - ❌ Removed
includeStylesoption (always enabled) - ❌ Removed
baseUrloption (uses provider default)
# Install dependencies
pnpm install
# Build
pnpm build
# Development mode
pnpm dev
# Type check
pnpm type-check
# Lint
pnpm lint
The Publish workflow publishes the package to npm when a version tag is pushed. It uses npm Trusted Publishing, so you do not need to log in to npm.
-
Add an entry under "What's Changed".
-
Increase the version. This changes
package.jsonand creates a git commit and avtag:npm version patch # 0.5.2 → 0.5.3 npm version minor # 0.5.2 → 0.6.0 npm version major # 0.5.2 → 1.0.0 -
Push the commit and the tag. The workflow type-checks, lints, builds and publishes:
git push --follow-tags
MIT © cloro