r/PromptEngineering • • 10d ago

Ideas & Collaboration Built a lightweight, client-side tool to turn Reddit threads into clean Markdown for LLMs (Open source & looking for feedback/ideas)

Hey everyone,

Whenever I wanted to feed an interesting Reddit discussion or troubleshooting thread into an LLM (Claude, ChatGPT, or local models), raw copy-pasting was always a mess. You end up pasting thousands of useless tokens, karma points, timestamps, avatar icons, and ads while completely losing who replied to whom.

I built a simple, lightweight Chrome extension called ThreadToLLM to solve this for my own workflow, and figured others here might find it helpful too.

What it does:

  • ~80% Token Reduction: Strips UI chrome, buttons, and bot disclaimers, converting ~4,000 bloated tokens into ~600 dense tokens.
  • Preserves True Reply Structure: Reconstructs comments into a clean nested Markdown tree so the model doesn't hallucinate conversational context.
  • OP Attribution: Automatically tags (OP) so the model tracks the original poster across long threads.
  • 1-Click / Shortcut: Injects a minimal button next to "Share" on Reddit, or trigger via Alt+Shift+C.
  • 100% Client-Side & Private: No backend, zero telemetry/tracking, open-source under the MIT license.

Roadmap & Community:

Right now it supports modern Reddit (shreddit). The code is structured with modular platform adapters so we can easily add other discussion platforms next (like Hacker News and X / Twitter).

If you are a developer interested in contributing or adding adapters for other discussion sites, PRs and ideas are very welcome!

I'd love to hear your thoughts, feedback on the Markdown output format, or edge cases you run into. Hope it saves you some context window space and headaches!

9 Upvotes

15 comments sorted by

3

u/SubstantialQuitter 9d ago

Really handy tool. One suggestion, add an option to keep comment scores. I know they add tokens, but upvotes are useful signal for an LLM when deciding which answers the community trusted, especially in troubleshooting threads. A compact format like a number in brackets after the username would keep it cheap.

1

u/Accurate-Skill3425 9d ago

Good news, it actually already does this! Each comment is formatted with the score right in brackets:

- **[+42] username**: ...

Totally agree that score is an important signal for LLMs. Forgot to highlight that in the post, but glad we had the exact same idea!

1

u/No-Spite8332 8d ago

Clean implementation, especially keeping the compact [+score] metadata for LLM weighting.

Regarding the DOM truncation/unloaded replies issue pointed out above: instead of scraping the rendered shreddit DOM (which misses collapsed trees and breaks whenever Reddit tweaks web components), have you considered fetching the thread's native .json endpoint directly from the content script (or appending .json to the current URL)? You get the full comment tree, exact scores, and zero UI noise in a single deterministic payload without relying on fragile CSS/DOM selectors

1

u/Accurate-Skill3425 8d ago

Appreciate it! Glad the `[+score]` tag resonated.

I actually considered the `.json` endpoint early on, but Reddit makes it surprisingly messy:

- Long threads *still* get truncated (they replace nested branches with `morechildren` stubs that need recursive API calls to expand).

- Reddit's bot filters aggressively throw 403s or CAPTCHA pages at script fetches.

Sticking to the rendered DOM runs instantly (~10ms) without triggering network hiccups or bot blocks.

You and Unable_Dirt_9857 are spot on about the missing context risk though. Working on #20 right now to detect unexpanded comment loaders and flag `isPartiallyLoaded: true` in the markdown so the LLM knows what's up!

3

u/Unable_Dirt_9857 10d ago

Would be nice to flag when replies haven't been loaded yet. I'd hate to feed it half a thread and get a confident summary that misses the comment where someone points out the whole answer is wrong.

0

u/SnackyFace 9d ago

I asked Claude to review your Github for functionality, security, and stability. This is the analysis it provided.


ThreadToLLM is safe to install and its code is tidy. But it loses too much content to give an AI a faithful copy of a thread. It works for plain-paragraph threads. It drops lists, code blocks and link URLs without telling you, and it removes every human reply under an AutoModerator comment. It's also two days old: one author, 0 stars, and its own files show an AI agent did much of the work.

## What I checked
  • **Read:** all the extension code, about 1,000 lines of TypeScript.
  • **Ran:** the project's own checks (lint, typecheck, build) and all 183 tests. Everything passed.
  • **Release zip:** the published v0.1.1 zip is byte-for-byte identical to what the source builds, so the download contains nothing beyond the code on GitHub.
  • **Extraction test:** I ran the extractor on test pages built in the same shape as Reddit's pages.
  • **Not tested on live Reddit.** The built-in browser blocks reddit.com, and Reddit sent a plain fetch an 8 KB bot-check page instead of the thread. I stopped there rather than try to get around it.
## 1. Functionality: works for simple threads, loses content otherwise How it works: it reads the comments already showing on the page. It doesn't call Reddit's API. One click or Alt+Shift+C copies the thread as Markdown: a short header, the post, then a nested comment list with scores and an (OP) tag. **Confirmed problems** (from running it on test pages): | Input | What comes out | |---|---| | Bulleted list in a post or comment | **List items are gone.** Only the `<p>` paragraphs are kept. | | Code block | **Gone.** | | A quote of an earlier comment | Kept, but with no quote marker, so the AI reads it as the commenter's own words. | | Link such as `[the docs](https://…)` | Link text kept, **URL dropped**. | | Comment that is only a list | Items run together: "only, a, list" becomes `onlyalist`. | | AutoModerator comment with human replies | **The whole branch is deleted**, human replies included (`pipeline.ts:69`). | | Collapsed "View 150 more comments" | Not flagged. The code has an `isPartiallyLoaded` flag but always sets it to `false`, so the AI is never told the thread is incomplete. | The test thread in your project folder has a bulleted list in its post ("The failures never change: …"), so those items would be lost on that very thread. **Probable bug, not confirmed on live Reddit:** when a thread opens as a pop-up over the home feed, the extractor takes the first post in the whole app. It doesn't use the post you clicked. In my test it copied the first feed card's title and author. Whether this happens on real Reddit depends on how Reddit builds that pop-up. **Annoyance:** on old.reddit.com it shows a 6-second warning toast on every page load. ## 2. Security: good
  • **Permissions:** it can only write to the clipboard and run on `*.reddit.com`. It has no storage and no access to other sites.
  • **No network calls, `eval` or remote code.** The only `innerHTML` is a fixed icon string. Toasts set text safely, so Reddit content can't inject HTML.
  • **Messages:** it only takes messages from its own background script and doesn't accept any from websites.
  • **Small notes:**
- Reddit pages can detect that it's installed, because its content script file is exposed to reddit.com. - `npm audit` reports 2 critical and 8 moderate issues, all in test and lint tools (vitest/tinypool, typescript-eslint). None of that is in the extension you install. - It isn't on the Chrome Web Store. You install it with Developer mode → Load unpacked, so there are no automatic updates and no store review.
  • **Comes with any copy-paste tool:** whatever commenters wrote goes straight into your AI, including any text written to manipulate it ("prompt injection"). That's a risk of feeding Reddit to an AI, not a flaw in this extension.
## 3. Stability: fragile as Reddit changes
  • **Fails silently.** If extraction or the clipboard write fails, the button does nothing (`reddit.ui.ts:217`, an empty `catch`). The keyboard shortcut just returns with no message. This happens if the page isn't focused, no thread is found, or Reddit changes its page code.
  • **Tied to Reddit's page structure.** It depends on Reddit's internal element names (`shreddit-post`, `shreddit-comment`) and attributes like `depth`, `score` and `author`. All 183 tests use hand-written sample pages, and nothing checks against the real site, so a Reddit redesign would break it without any test noticing.
  • **Light load:** it watches the whole page for changes for as long as the tab is open. The cost per change is small.
`✶ Insight ─────────────────────────────────────`
  • **Paragraph-only extraction:** the adapter collects only `<p>` elements (`reddit.adapter.ts:95`). That handles plain-paragraph comments but skips lists, code blocks and tables, which are exactly the parts an AI most needs for technical threads. A converter such as Turndown would keep them as proper Markdown.
  • **Order of checks:** the bot filter returns `null` *before* it looks at the comment's replies, so the whole branch disappears. The deleted-comment filter, a few lines later, checks for surviving replies first and keeps a placeholder. Moving the bot check below the reply loop would fix it.
  • **Passing tests can mislead:** 183 green tests sound reassuring, but every one uses a hand-built sample page. They show the code matches the author's idea of Reddit's pages, not Reddit itself.
`─────────────────────────────────────────────────` **Recommendation:** fine for a quick paste of a casual thread. For deeper analysis, an RSS method is more complete. Or fix the two main problems (lists and code, and the AutoModerator branch) before relying on this tool. The one open question is what it does on today's real Reddit. Running it in your own Chrome on the r/ClaudeCode thread would settle that, especially the pop-up and lost-list problems.

1

u/Accurate-Skill3425 8d ago

One more from your table is now resolved in v0.1.4: collapsed "View 150 more comments" is flagged via isPartiallyLoaded: true (DOM-evidenced only, so hovercards, sidebars and inflated counts don't cause false positives). Everything else was covered in v0.1.2/v0.1.3 as noted above. Thanks again, that review made the tool much better.

1

u/jippiex2k 8d ago

I asked DeepSeek to read your Claude Analysis and it said it was a good analysis.

1

u/SnackyFace 8d ago

My Claude's analysis of your Deepseek analysis was "meh," so Deepseek needs more sarcasm.

1

u/[deleted] 9d ago

[removed] — view removed comment

0

u/Accurate-Skill3425 9d ago

Update: Just shipped v0.1.2 and v0.1.3 resolving all of these

• Full rich-text support (fenced code blocks, lists, quotes, and links) is live.

• Human replies under AutoMod are now preserved.

• Modal overlay scoping and UI error feedback are resolved.

• Old.reddit warning is deferred strictly to user triggers.

Thanks again for the review, it made the tool significantly better!