Skip to main content
GrN.dk

Main navigation

  • Articles
  • Cases
  • Contact
  • Your Digital Project Manager
  • About Greg Nowak
  • Services
  • Portfolio
  • Container
    • Excel Freelancer
    • Kubuntu - tips and tricks
    • Linux Apache MySQL and PHP
    • News
    • Image Gallery
User account menu
  • Log in

Breadcrumb

  1. Home

How to Bulk Delete Cloudflare DNS Records Without Browser Console JavaScript

By Greg Nowak. Last updated 2026-07-11.

If you are looking for browser-console JavaScript to bulk-delete Cloudflare DNS records, you probably have a cleanup problem rather than a JavaScript problem: an untidy import, a completed migration, or years of records left behind by former vendors.

Running a click-loop in DevTools used to feel like the quickest answer. It was also brittle. A dashboard update could break the script halfway through, while an overly broad selector could remove records you never intended to touch. Cloudflare now provides first-party bulk operations in its dashboard and API. The safer question is therefore not “How can I click Delete faster?” but “Which workflow gives us a reviewable change and a credible recovery path?”

Choose the right cleanup method

Situation Best method Why
One zone with an obvious selection Dashboard bulk delete Fast, visible, and easy for a colleague to review
Records match a clear rule List and delete through the API Repeatable filtering with an explicit preview
Deletes and replacements belong together Batch API One reviewed request containing the complete change set
The zone needs extensive reconstruction Export, edit, and import A before-and-after file is often clearer than hundreds of individual actions
A practical decision matrix for Cloudflare DNS cleanup.

Use dashboard bulk delete for straightforward jobs

On the DNS Records page, select the records, choose Delete records, and type DELETE when prompted. As of July 2026, Cloudflare makes this available on every plan. One action can include up to 200 records on Free zones and 3,500 on Pro, Business, and Enterprise zones.

This is usually the best option when a human can confidently identify the records. Before confirming, export the zone and save the file with the change ticket. Treat that export as recovery material, not a magic Undo button: restoration still needs to be checked carefully.

Review these records separately before any broad deletion:

  • MX, SPF, DKIM, and DMARC records that protect email delivery;
  • TXT records used for domain ownership or SaaS verification;
  • CAA, SRV, and delegated NS records;
  • records supporting customer logins, redirects, certificates, or migration fallbacks.

For repeatable cleanup, preview through the API

Use a narrowly scoped API token with DNS Read for discovery and DNS Write only when deletion is required. Cloudflare recommends API tokens instead of the older Global API Key.

The list endpoint supports structured filters for type, name, content, tags, and comments. Avoid building automation around its free-text search parameter: Cloudflare explicitly reserves that feature for human use and may change its behaviour.

The following example downloads a snapshot, checks that Cloudflare reported success, and creates a reviewable list of matching TXT records. Replace the example domain and selection rule before running it:

export ZONE_ID="your_zone_id"
export CLOUDFLARE_API_TOKEN="your_token"

curl --fail-with-body --silent --show-error \
  "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records?per_page=50000" \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  > dns-records.json

jq -e '.success == true' dns-records.json > /dev/null

jq -r '.result[]
  | select(
      .type == "TXT" and
      (.name == "old.example.com" or
       (.name | endswith(".old.example.com")))
    )
  | [.id, .type, .name, .content]
  | @tsv' dns-records.json > candidates.tsv

wc -l candidates.tsv
column -t -s $'\t' candidates.tsv

Stop here and inspect candidates.tsv. Confirm the count, names, values, and business purpose with whoever owns the affected service. For zones exceeding the requested page size, process every page reported in result_info.total_pages; never assume that one response contains the whole zone.

Delete only the reviewed record IDs

Once the candidate file has been approved, feed its first column to the documented delete endpoint:

cut -f1 candidates.tsv > approved-record-ids.txt

while IFS= read -r id; do
  curl --fail-with-body --silent --show-error \
    --request DELETE \
    "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$id" \
    --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
  echo
done < approved-record-ids.txt

Keeping discovery and deletion as separate steps is intentional. It produces an approval artifact, prevents a changing query from silently expanding the deletion, and makes the operation easier to audit. Do not place long-lived tokens in source control, shared chat, or shell scripts committed to a repository.

Use the batch endpoint for coordinated changes

If records must be deleted and replaced during the same change window, Cloudflare’s /dns_records/batch endpoint can carry deletes, patches, puts, and posts in one request. Operations run in that order. A minimal deletion body looks like this:

{
  "deletes": [
    { "id": "RECORD_ID_1" },
    { "id": "RECORD_ID_2" }
  ]
}

Cloudflare executes a batch as one database transaction, but propagation across its distributed network is not atomic. Clients may briefly observe different stages of a coordinated change. Plan the sequence, retain old destinations where practical, and validate the finished state rather than assuming a successful API response proves the service works.

Finish with service-level checks

  1. List the zone again and confirm that only approved IDs disappeared.
  2. Resolve important names through more than one public DNS resolver.
  3. Test the website, redirects, email flow, certificate issuance, and vendor verification affected by the change.
  4. Record what was removed, who approved it, and where the export and candidate list are stored.

For a deeply cluttered zone, rebuilding from a reviewed export may be clearer than running hundreds of deletes. Cloudflare currently limits imported zone files to 256 KiB and the import API to three requests per minute per user, so include those constraints in the plan.

If your zone supports revenue, email, or customer access and nobody is entirely sure which records are still needed, Greg can help turn the cleanup into a controlled DNS change with clear ownership, review, and validation.

Related on GrN.dk

  • AI automations need a spend dashboard before the first runaway bill
  • When AI writes JSON, one bad field can break the workflow
  • AI search is eating the click: measure the queries before rewriting pages

Need help with this kind of work?

Plan a safer DNS cleanup with Greg Get in touch with Greg.

Sources

  • Batch record changes · Cloudflare DNS docs
  • List DNS Records · Cloudflare API
  • Delete DNS Record · Cloudflare API
  • Import and export records · Cloudflare DNS docs
Last modified
2026-07-11

Tags

  • Cloudflare
  • DNS
  • DNS cleanup
  • Cloudflare API
  • Operations

Review Greg on Google

Greg Nowak Google Reviews

 

Illustrated infographic summarizing: Shorter TLS certificates expose every renewal you never automated
Shorter TLS certificates expose every renewal you never automated
2026-07-26

Shorter TLS lifetimes leave less room for manual handoffs and faulty deploy hooks. Build a renewal path that protects service availability.

Illustrated infographic summarizing: One Timeout, Two Orders: Make AI Actions Safe to Retry
One Timeout, Two Orders: Make AI Actions Safe to Retry
2026-07-25

A timed-out AI action may already have succeeded. Stable keys, durable ledgers, queues and stored results prevent a routine retry from duplicating real work.

Illustrated infographic summarizing: Your AI Visibility Dashboard Needs a Methodology, Not More Charts
Your AI Visibility Dashboard Needs a Methodology, Not More Charts
2026-07-24

A practical framework for measuring AI-search visibility with fixed prompts, repeated tests, separate metrics, retained evidence, and honest reporting.

Illustrated infographic summarizing: AI Admin APIs Are Here—But Your Directory Is Still the Source of Truth
AI Admin APIs Are Here—But Your Directory Is Still the Source of Truth
2026-07-23

New AI admin APIs can automate access and spend controls, but reliable governance still starts with authoritative directory data and clear ownership.

Illustrated infographic summarizing: OpenAI Presence Arrived—But Is Your Workflow Ready for an Agent?
OpenAI Presence Arrived—But Is Your Workflow Ready for an Agent?
2026-07-22

Before an AI agent can take on real work, its workflow needs clear scope, permissions, handoffs, evaluation cases, and production monitoring.

Illustrated infographic summarizing: Chatbot Transcripts Quietly Became a Retention and Redaction Problem
Chatbot Transcripts Quietly Became a Retention and Redaction Problem
2026-07-21

Chatbot transcripts spread across providers, logs and support tools. Here is how to map each copy, redact sensitive data and test deletion properly.

Illustrated infographic summarizing: Cloudflare Service Keys Stop in September: Find Every Caller
Cloudflare Service Keys Stop in September: Find Every Caller
2026-07-20

Cloudflare Service Keys stop working on September 30, 2026. Here is how to find every caller, move to scoped API tokens and avoid a late outage.

Illustrated infographic summarizing: Your AI Workflow Needs an Acceptance Test Before It Meets Customers
Your AI Workflow Needs an Acceptance Test Before It Meets Customers
2026-07-19

A practical way to test AI workflows using realistic scenarios, tool checks, human rubrics, regression suites, and clear release gates.

Three cover candidates for The Goats Were Load-Bearing fanned on a dark background: an ember-lit door, three slow knocks, and a founders' ledger
The Goats Were Load-Bearing: a fantasy where the bill always comes due
2026-07-19

A teaser for the upcoming darkly comic fantasy novel The Goats Were Load-Bearing — a village, a door that must stay poor, and the worst possible time to sell the herd. Readers pick the cover.

Vegan Power game: the yellow player catches falling fruit while a chicken and a cow look on
Vegan Power: The Little Game About Eating Fruit, Not Friends
2026-07-19

Vegan Power is a free browser game where you catch fruit, dodge the animals, protect seven hearts, and chase a better high score.

More articles
RSS feed

GrN.dk web platforms, web optimization, data analysis, data handling and logistics.