ChatGPT & Claude to PDF Converter
Turn AI conversations and Markdown notes into clean, print-ready PDFs with crisp typography, formatted tables, and bordered code blocks.
Next.js Rate Limiting Notes
Nov 26, 2026 · TechnicalImplementing Rate Limiting in Next.js API Routes
User: How should I implement a lightweight sliding-window rate limiter in Next.js without adding heavy dependencies?
Assistant: For single-instance deployments or edge prototypes, you can use an in-memory Map, while multi-instance production apps should back the window with Redis (INCR + EXPIRE).
1. Key Trade-offs
| Approach | Latency | Multi-Instance Safe | Setup Complexity |
|---|---|---|---|
| In-Memory Map | < 0.1 ms | No | Minimal |
| Redis Fixed Window | ~1–3 ms | Yes | Low |
| Redis Sliding Window | ~2–5 ms | Yes | Medium |
2. Production Redis Helper
import { Redis } from "ioredis";
export async function checkRateLimit(
redis: Redis,
key: string,
limit = 60,
windowSec = 60
): Promise<{ allowed: boolean; remaining: number }> {
const count = await redis.incr(key);
if (count === 1) {
await redis.expire(key, windowSec);
}
return {
allowed: count <= limit,
remaining: Math.max(0, limit - count),
};
}
Tip: Always return standard
X-RateLimit-RemainingandRetry-Afterheaders so API consumers can back off cleanly.
How it works
- 1Paste Markdown or copied ChatGPT/Claude text into the left editor, or load the built-in sample conversation.
- 2Set your document title, choose a typography preset (Technical, Academic, or Minimal), and adjust font size.
- 3Click Print / Save as PDF to open your browser's print dialog—all web toolbars and navigation are automatically hidden.
- 4Optionally download a self-contained HTML snapshot for archiving or sharing offline.
Frequently asked questions
Are my ChatGPT or Claude conversations uploaded to a server?
No. Markdown parsing, HTML sanitization, and PDF print rendering run 100% inside your browser tab. Your prompts and outputs never leave your device.
Why does Print / Save as PDF look cleaner than printing ChatGPT directly?
Printing directly from ChatGPT or Claude includes sidebars, input boxes, copy buttons, and clipped code scrollbars. This tool strips all web chrome via print CSS and wraps code blocks cleanly across pages.
How do I save the output as a PDF file?
Click the Print / Save as PDF button and set your browser's Destination to 'Save as PDF'. Enable 'Background graphics' if you want tinted code blocks and table headers.
Does it support GitHub-Flavored Markdown tables and fenced code blocks?
Yes. Pipe tables, fenced code blocks, blockquotes, nested lists, and inline formatting are rendered with page-break protection so tables and code snippets stay readable.
Is pasted HTML sanitized against scripts?
Yes. Any <script>, <iframe>, <object>, inline event handlers, or javascript: links are stripped before rendering the preview or exporting HTML.
Related tools
View all tools →Convert pasted AI HTML or ChatGPT conversations.json exports into Obsidian Markdown.
Strip Markdown stars, curly quotes, em-dashes, and invisible Unicode characters.
Count tokens and compare API costs across GPT-6.2, Claude 5.5, and Gemini 4.