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

Join my community / free newsletter — sign up here

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: AI Agents Need a Spending Brake, Not Just a Billing Dashboard
AI Agents Need a Spending Brake, Not Just a Billing Dashboard
2026-08-08

AI agent costs can climb inside a single workflow. Runtime budgets, loop detection, outcome metrics, and safe handoffs keep that spending under control.

Illustrated infographic summarizing: Drupal 12 Slipped to December. Drupal 10 Still Runs Out of Road
Drupal 12 Slipped to December. Drupal 10 Still Runs Out of Road
2026-08-07

Drupal 12 arrives as Drupal 10 support ends in December 2026. Moving to Drupal 11.3+ first keeps two mandatory upgrades manageable.

Illustrated infographic summarizing: EU OpenAI Residency Is a Migration Project, Not a Dashboard Toggle
EU OpenAI Residency Is a Migration Project, Not a Dashboard Toggle
2026-08-05

An EU-resident OpenAI API setup needs a new project, regional routing, dependency and state migration, compatibility testing, and clear governance evidence.

Illustrated infographic summarizing: AI Images Need a Chain of Custody, Not Just a Disclosure Label
AI Images Need a Chain of Custody, Not Just a Disclosure Label
2026-08-04

AI image labels are only the endpoint. Learn how to test C2PA credentials through editing, CMS, CDN and agency handoffs while preserving evidence.

Illustrated infographic summarizing: MCP Just Went Stateless: Audit the Integrations Behind Your AI Tools
MCP Just Went Stateless: Audit the Integrations Behind Your AI Tools
2026-08-03

The 28 July 2026 MCP release removes protocol sessions and changes discovery, tasks, caching, OAuth and tracing. A practical guide to auditing the move.

Illustrated infographic summarizing: SEO Trends for 2026: What Actually Changed Since 2024
SEO Trends for 2026: What Actually Changed Since 2024
2026-08-03

A practical guide to what changed in SEO between 2024 and 2026, from AI and multimodal search to Core Web Vitals, privacy and local visibility.

Illustrated infographic summarizing: INP and Green SEO Share a Backlog: Cut the Work Every Visit Repeats
INP and Green SEO Share a Backlog: Cut the Work Every Visit Repeats
2026-08-03

INP and sustainable web work often expose the same waste. Use field data, profiling, caching and performance budgets to build one practical backlog.

Illustrated infographic summarizing: AI crawler policy now has verbs: separate search, RAG, and training
AI crawler policy now has verbs: separate search, RAG, and training
2026-08-02

AI crawler rules now need separate decisions for search, RAG, and training, backed by practical testing across robots.txt, CDNs, WAFs, and CMS controls.

Illustrated infographic summarizing: WordPress Supports Old PHP; Your Production Server Shouldn’t
WordPress Supports Old PHP; Your Production Server Shouldn’t
2026-08-01

WordPress still runs on legacy PHP, but compatibility is not a security policy. Build and test your upgrade path before PHP 8.2 support ends.

Illustrated infographic summarizing: The AI-built tool your team relies on needs an owner
The AI-built tool your team relies on needs an owner
2026-07-31

AI-built internal tools can become business-critical before anyone owns them. Here is how to secure, review, monitor, and retire them without blocking useful work.

More articles
RSS feed

Footer

  • All articles
  • Contact

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