npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

url-to-json-markdown

v1.0.7

Published

A TypeScript library that fetches URLs and converts them to structured JSON and Markdown format.

Readme

url-to-json-markdown

NPM version

A TypeScript library that fetches URLs and converts them to structured JSON and Markdown format.

Built by 16x Writer and 16x Eval team.

Installation

npm install url-to-json-markdown

Usage

import { urlToJsonMarkdown } from 'url-to-json-markdown';

// Reddit post (using fallback without credentials)
const post = await urlToJsonMarkdown(
  'https://www.reddit.com/r/example/comments/12345/title/'
);
console.log(post.title); // "Post Title"
console.log(post.content); // "# Post Title\n\nPost content...\n\nby _username_ (↑ 123) 12/25/2024"
console.log(post.type); // "reddit"

// Reddit post with credentials (more reliable)
const postWithCreds = await urlToJsonMarkdown(
  'https://www.reddit.com/r/example/comments/12345/title/',
  {
    clientId: 'your_client_id',
    clientSecret: 'your_client_secret',
  }
);

// Reddit post with comments included
const postWithComments = await urlToJsonMarkdown(
  'https://www.reddit.com/r/example/comments/12345/title/',
  {
    clientId: 'your_client_id',
    clientSecret: 'your_client_secret',
    includeComments: true,
  }
);
// Will include "## Comments" section with tree-structured comments

// Reddit comment
const comment = await urlToJsonMarkdown(
  'https://www.reddit.com/r/example/comments/12345/comment/abc123/'
);
console.log(comment.title); // "First line of comment..."
console.log(comment.content); // "# Comment by username\n\nComment text...\n\nby _username_ (↑ 45)"
console.log(comment.type); // "reddit"

// Reddit comment with child comments/replies
const commentWithReplies = await urlToJsonMarkdown(
  'https://www.reddit.com/r/example/comments/12345/comment/abc123/',
  { includeComments: true }
);
// Will include "## Replies" section with tree-structured child comments

// Generic web page
const webpage = await urlToJsonMarkdown('https://example.com/article');
console.log(webpage.title); // "Article Title"
console.log(webpage.content); // "# Article Title\n\nMain content as markdown..."
console.log(webpage.type); // "generic"

API

urlToJsonMarkdown(url: string, options?: RedditOptions): Promise<UrlToJsonResult>

Parameters:

  • url - The URL to fetch and convert
  • options - Optional Reddit configuration

Reddit Options:

interface RedditOptions {
  clientId?: string;
  clientSecret?: string;
  includeComments?: boolean;
}
  • clientId & clientSecret - Reddit API credentials for more reliable access
  • includeComments - Include comments in a tree structure (Reddit posts) or child comments/replies (Reddit comments)

Return Type:

interface UrlToJsonResult {
  title: string;
  content: string;
  type: 'reddit' | 'generic';
}

Reddit Access

For Reddit URLs, the library supports two modes:

  1. Fallback mode (no credentials): Uses browser user agent to access Reddit's public JSON API. May be subject to rate limiting.

  2. Authenticated mode (with credentials): Uses Reddit OAuth API for more reliable access. Requires Reddit app credentials.

To get Reddit credentials:

  1. Go to https://www.reddit.com/prefs/apps
  2. Create a new app (script type)
  3. Use the client ID and secret

Supported URLs

  • Reddit: Posts and comments from reddit.com
  • Generic: Any website with automatic content extraction