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.
--quit-edge to quit it automatically.
uv (the script uses
uv run)
uv run
Close Microsoft Edge, or plan to use
--quit-edge.
Run a dry run first to see what would be deleted:
When the counts look right, delete for real:
Or omit arguments to use the YAML config file:
| 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. |
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.
#!/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."""
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.
# 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
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.
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.