← Writing
4 min read Updated Jul 26, 2026

Bulk Delete Archived Claude Code Sessions

Claude Code on the web has no bulk delete. Open claude.ai/code, open DevTools, paste a short script that calls GET /v1/sessions then DELETE /v1/sessions/{id} in batches of 10. No API key. Uses your logged-in browser session. Review the limitations before you run it.

Claude Code has no bulk delete for archived sessions. The web UI at claude.ai/code lets you filter Active, Archived, or All, but each row only has a single trash control. To clear hundreds of sessions, open the browser console on that page and run the script below. It calls the same sessions API the UI uses, in batches of 10, and reloads when it finishes.

I hit this with more than 300 archived sessions in the sidebar. I was not going to click trash 300 times.

How to bulk delete Claude Code sessions

  1. Sign in and open claude.ai/code.
  2. Open the browser console: Cmd+Option+J on Mac, Ctrl+Shift+J on Windows or Linux.
  3. Paste the script, press Enter, and wait for the progress logs.
  4. When it prints Done!, the page reloads.
(async () => {
  const headers = {
    "anthropic-beta": "ccr-byoc-2025-07-29",
    "anthropic-client-feature": "ccr",
    "anthropic-client-platform": "web_claude_ai",
    "anthropic-version": "2023-06-01",
    "content-type": "application/json"
  };

  // Fetch all session IDs (handles pagination)
  let allIds = [];
  let url = '/v1/sessions';
  while (url) {
    const resp = await (await fetch(url, { headers })).json();
    const sessions = resp.data || resp;
    sessions.forEach(s => allIds.push(s.id));
    url = resp.has_more && resp.last_id
      ? '/v1/sessions?after_id=' + resp.last_id
      : null;
  }
  console.log(`Found ${allIds.length} sessions. Deleting...`);

  // Delete in batches of 10
  let deleted = 0, failed = 0;
  for (let i = 0; i < allIds.length; i += 10) {
    const batch = allIds.slice(i, i + 10);
    await Promise.all(batch.map(id =>
      fetch('/v1/sessions/' + id, { method: 'DELETE', headers, body: '{}' })
        .then(r => r.ok ? deleted++ : failed++)
        .catch(() => failed++)
    ));
    console.log(`Progress: ${deleted + failed}/${allIds.length} (deleted=${deleted}, failed=${failed})`);
  }
  console.log(`Done! Deleted ${deleted}, failed ${failed}`);
  location.reload();
})();

That is the whole fix for “how do I delete all Claude Code sessions” and the usual variants: delete session, delete old sessions, clear archived sessions.

What the script does

It page-walks GET /v1/sessions (about 200 sessions per page in my runs), collects every id, then fires DELETE /v1/sessions/{id} ten at a time so you do not hammer the endpoint. Progress prints to the console. When finished, it reloads the tab so the sidebar matches the API.

No API key, no personal access token, no third-party extension. The request runs in your logged-in tab, so the browser sends the auth the product already trusts.

Optional: delete only archived sessions

The default script deletes every session ID the list endpoint returns. If you only want archived rows gone, log one object first and filter on the status field your account actually uses:

// After fetching `sessions`, keep only archived before pushing ids:
// sessions.forEach(s => {
//   if (s.status === 'archived' || s.archived === true) allIds.push(s.id);
// });

Field names can change. Inspect console.log(sessions[0]) once before you delete at scale.

Why not click the UI?

I tried automating the trash icon first. It is a bad path:

  • Synthetic .click() often lies. React handlers do not always fire. You get a “Session deleted” toast while the DELETE never lands.
  • The sidebar is paginated. You only see a couple dozen rows. The API can return hundreds. Scroll, wait, repeat.
  • It is slow. Roughly a second plus animation per delete. Three hundred sessions is several minutes of watching UI. The API path finished under 30 seconds for me.

If you came here from “claude code archive session” or “claude code delete old sessions,” the API path is the reliable one.

Limitations (read these)

  • Scope is the web sessions API, not local Claude Code / CLI history on disk.
  • Default run deletes every listed session, not “archived only,” unless you add a filter.
  • Beta request headers can change. If deletes start failing, compare Network tab traffic from a manual delete and update the header set.
  • This is destructive. There is no undo in the script. If a session still has work you need, leave the page and do not run it.
  • Only run it on claude.ai while you are logged into your own account. Never paste it on another origin.

If you are still setting up Claude Code itself, I wrote up my Claude Code setup separately. That post is about plugins and workflow. This one is only about clearing the session list.

Frequently asked questions

How do I delete all Claude Code sessions at once?

There is no bulk delete in the Claude Code web UI. Open https://claude.ai/code while logged in, open the browser console, and paste the script on this page. It lists every session from GET /v1/sessions, then deletes each ID with DELETE /v1/sessions/{id} in batches of 10.

How do I delete archived Claude Code sessions without clicking one by one?

Filter the sidebar to Archived if you want, then run the console script. The script talks to the sessions API, not the trash icon. That is why it finishes hundreds of sessions in tens of seconds instead of minutes of UI clicks.

Is there a Claude CLI command to bulk delete sessions?

This guide is for Claude Code on the web at claude.ai/code. Local Claude Code / CLI history lives on your machine and is a different storage path. Do not expect this browser script to clear local CLI sessions.

Do I need an Anthropic API key to bulk delete sessions?

No. The script runs inside your already authenticated browser tab. fetch() reuses the cookies and headers from your login. Do not paste the script into a random site or share a logged-in session while it runs.

Will this delete active Claude Code sessions too?

Yes, unless you change the script. GET /v1/sessions returns the sessions the API exposes for your account. The default script deletes every ID it receives. If you only want archived rows gone, inspect one session object first and filter on the status field before calling DELETE.

Karthik Kamalakannan
Karthik Kamalakannan

I founded Skcript. Over the last , I've built highly scalable B2B software for both Skcript and its clients. Design-led products, rock-solid stability, and a bias for shipping.