Overview

This script removes Microsoft Edge browsing history entries whose URL contains a given substring. It operates directly on Edge's SQLite history databases under each profile, cleaning up related rows across every dependent table so the deletion is complete.

Use it when you want to purge specific domains or paths from your local history without clearing everything, or when you maintain a standing list of sites to exclude from your record.

Before you run

Edge must be closed Edge locks its history database while running. Close Edge before executing the script, or pass --quit-edge to quit it automatically.

Quick start

  1. Close Microsoft Edge, or plan to use --quit-edge.

  2. Run a dry run first to see what would be deleted:

    Dry run — single substring
    uv run delete_edge_history.py amazon.com --dry-run
  3. When the counts look right, delete for real:

    Delete — single substring
    uv run delete_edge_history.py amazon.com
  4. Or omit arguments to use the YAML config file:

    Delete — config file substrings
    uv run delete_edge_history.py

CLI options

Flag / argument Description
substring … One or more URL substrings to match (e.g. amazon.com). If omitted, substrings are read from delete_edge_history.yml in the same directory as the script.
--dry-run Report matching URL and visit counts without deleting anything.
--quit-edge Quit Microsoft Edge automatically if it is running, then proceed.

Dependencies

The script is self-contained: runtime dependencies are declared at the top of delete_edge_history.py using PEP 723 inline script metadata. No pyproject.toml or virtual environment setup is required — uv run reads the header and provisions an isolated environment on each invocation.

delete_edge_history.py (header)
#!/usr/bin/env -S uv run python
# /// script
# requires-python = ">=3.12"
# dependencies = [
#   "pyyaml>=6.0",
# ]
# ///

"""Delete Microsoft Edge history entries whose URL contains a given substring."""

Config file

delete_edge_history.yml is a YAML list of substrings. When you run the script with no positional arguments, every entry in the list is processed in order.

delete_edge_history.yml
# Do not forget to close Edge before running this script
- amazon.com
- x.com
- google.com
- news.ycombinator.com
- old.reddit.com
- reddit.com
- youtube.com
- etsy.com
- ebay.com
- chase.com

How it works

The script locates history databases at ~/Library/Application Support/Microsoft Edge/*/History, one per Edge profile. For each substring it builds a SQL LIKE pattern (with % and _ escaped) and counts matching URLs and visits.

On a real run it deletes rows from dependent tables first (search terms, visited links, segments, annotations, visit sources, and others), then removes the matching visits and URLs. Output reports counts per profile and per substring.

Multiple profiles If you use more than one Edge profile, the script processes every profile database it finds and prints results for each.

Example output

Dry run
Would delete 142 URL(s) and 891 visit(s) in profile 'Default' matching 'amazon.com' Dry run complete for 'amazon.com': 142 URL(s) and 891 visit(s) matched.
Live delete
Deleted 142 URL(s) and 891 visit(s) in profile 'Default' matching 'amazon.com' Done for 'amazon.com': removed 142 URL(s) and 891 visit(s).

Source

The script lives in the tools repo alongside its config file: delete_edge_history.py and delete_edge_history.yml. Dependencies are embedded in the script via PEP 723 — there is no separate project manifest to maintain.