Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
H

HostsFileEditor

> 开发工具
Open source

Easily edit and manage the hosts file for Windows

1.2K stars0 likes0 views
WebsiteGitHub

About

Easily edit and manage the hosts file for Windows

A fast, friendly editor for the Windows hosts file. The Windows hosts file (%WinDir%\System32\drivers\etc\hosts) maps hostnames to IP addresses before DNS is consulted — handy for pointing a domain at a local dev server, blocking sites, testing deployments, or switching between environments. Editing it by hand in Notepad is tedious and error-prone. Hosts File Editor turns it into a proper table you can cut, copy, paste, enable, disable, sort, filter, and archive — with full undo/redo and a one-click toggle for the whole file.

It runs as a standard user and elevates on demand (a single UAC prompt) only when you actually save changes to the hosts file, so day-to-day viewing, archiving, and backups need no admin rights.

main modern editor (light)

Features

  • Cut, copy, paste, duplicate, enable, disable and move one or more entries at a time
  • Filter and sort when there are a large number of host entries
  • Quickly enable and disable the entire hosts file
  • Archive and restore various hosts file configurations (presets) when switching between environments
  • Merge another hosts file into the current one, skipping duplicates
  • Automatically ping endpoints to check availability, with a status-bar progress indicator
  • Switch presets straight from the taskbar — right-click the app for a Jump List of your archives
  • Full command line for scripting: switch presets, enable/disable, import/merge
  • Global shortcut key (default Ctrl+Shift+H) to hide/restore the classic edition from the tray
  • Modern variant supports light and dark themes

main classic editor with optional archive visible on right

tray icon with context menu

Usage Notes

By default the classic edition closes to the tray. To exit completely you must select Exit from the File menu or tray context menu. Only one instance of the application is allowed at a time. If you try to open it again it will just activate the previously running instance.

When selecting rows to move, delete, copy, or cut be sure to select the entire row using the row header cell. If no entire rows are selected, cut, copy, paste, and delete apply individually to the selected cells.

Using the filter and sort while editing is quirky. The filter and sort are applied once a cell is edited so your cell may change positions or disappear depending on the current sort and filter.

Command line

Both editions include a headless command line (v1.5.0 classic / v1.2.0 modern) so scripts can switch presets and toggle the hosts file — for example, applying a preset before launching a program and restoring it afterward:

hfe -s MyHosts1
program.exe
hfe -s DefaultHosts

Commands

Command Effect
apply (alias -s, switch) Switch the hosts file to a saved preset (archive)
enable Enable the hosts file
disable Disable the hosts file (renames it aside)
import Replace the hosts file with ``, then save
merge Merge `` into the hosts file, skipping duplicates, then save
list List available presets
help (--help, -h) Show usage

Presets are the archives you save in the app (the Archive feature); apply matches the archive name case-insensitively, with or without its file extension.

Exit codes: 0 success · 1 runtime error (preset or file not found, permission declined) · 2 usage error (unknown or malformed command). Errors print a one-line message to stderr.

hfe.exe vs HostsFileEditor.exe

Two executables run the same commands:

  • hfe.exe — a small console launcher that ships next to the app. Use this in scripts: it is a console app, so cmd and PowerShell wait for it to finish before running the next line, and its output pipes/redirects naturally. Store installs also register hfe on PATH (an app-execution alias), so hfe -s MyHosts1 works from any console.
  • HostsFileEditor.exe — the app itself also accepts the same commands and runs them headless (no window). Because it is a windowed app, cmd does not wait for it — wrap it as start /wait "" HostsFileEditor.exe -s MyHosts1 for sequential steps, or just use hfe.exe.

Run with no command and the app opens normally.

Both editions installed? The classic and modern Store apps each register the same hfe alias. Windows treats the duplicate as a conflict, so which edition owns hfe isn't guaranteed — pick the one you want under Settings → Apps → Apps & features → App execution aliases (Windows 11: Advanced app settings → App execution aliases). Each Store package also keeps its own isolated app data, so hfe list reflects whichever edition the alias points at, which may differ from the other edition's window. If you script with hfe, install just the edition you script against — or call that edition's hfe.exe by full path. Portable (zip) builds are unpackaged and don't register the alias at all, so this is a Store-install-only concern (and only the classic edition ships a portable build).

Permissions

Commands that change the hosts file need administrator rights, exactly like saving in the GUI: run from an elevated console for silent operation, or accept the single UAC prompt per command. A declined prompt cancels cleanly with exit code 1. list and help never need elevation.

Note: the CLI runs independently of an open GUI window — if the editor is open with unsaved changes, a CLI change to the hosts file isn't reflected there until you refresh (F5), and saving stale GUI edits afterward overwrites the CLI's change (last writer wins).

Download

Runs on Windows 10 and 11, x64 or ARM64. Two editions are available — pick whichever you prefer; they share the same core and features.

Microsoft Store — recommended

Installs and updates automatically, with no separate download:

  • Hosts File Editor (modern) — the new WinUI edition
  • Hosts File Editor (classic) — the classic WinForms edition

Portable — v1.5.2

The classic edition rebuilt on .NET 10: fully self-contained (no runtime to install), runs as a standard user, and elevates on demand (a single UAC prompt) only when you save changes to the hosts file. Binaries are signed. Download directly from GitHub Releases:

  • Download v1.5.2 portable — x64
  • Download v1.5.2 portable — ARM64

What's new in v1.5.2 (classic) / v1.2.2 (modern): a small quality patch. The modern edition no longer lets list rows bleed over the status bar on very large hosts files (100K+ entries) — a WinUI rendering bug that spilled the bottom rows past the list is now held off at the source, so the status bar stays clean at any list size. Both editions now show a clear "Invalid host names" validation message for a bad host name instead of a blank one. See the full release notes.

What's new in v1.5.1 (classic) / v1.2.1 (modern): a quality & robustness patch following the v1.5.0 / v1.2.0 feature release. The command line no longer risks losing a saved (disabled) hosts configuration on a repeated disable, and reports ambiguous preset names instead of guessing. The classic edition now carries your settings forward across updates (window size, auto-ping, the global shortcut) instead of resetting them, keeps the tray icon and toggle in sync after a command-line change, and its taskbar Jump List survives Store updates. The modern edition fixes a rare crash when a background merge/import overlapped a ping, and a Jump List preset clicked during a reload now opens. Plus smaller polish: paste-while-sorted appends predictably, merges don't ping discarded duplicates, and clearer messages. See the full release notes.

What's new in v1.5.0 (classic) / v1.2.0 (modern): a feature release. A full command line in both editions plus a new hfe.exe console launcher — switch presets, enable/disable, import, and merge from scripts (Store installs put hfe on PATH). A taskbar Jump List: right-click the app icon to open any preset directly. File → Merge combines another hosts file into the current one, skipping duplicates (undoable). The modern edition gains Sort options next to the filter, and the IP column now sorts numerically in both editions (8.8.8.8 before 10.0.0.2 before 10.0.0.10, IPv6 after IPv4). Auto-ping shows a status-bar progress indicator while pings are in flight, flags per-entry failures (modern gets an error badge with tooltip), and pings immediately when enabled. The classic edition adds a global shortcut (default Ctrl+Shift+H, configurable) to hide/restore from the tray, its text filter is now case-insensitive to match modern, the parser validates IPs strictly at parse time, and the portable zip dropped ~9 MB of unused libraries. See the full release notes.

What's new in v1.4.1: a small maintenance patch — the classic edition no longer targets the wrong entry when you Insert or Move right after a Move (the current-row anchor is restored by identity), and the modern edition skips a redundant filter pass on very large selections. See the full release notes.

What's new in v1.4.0: a broad performance pass for very large hosts files — smaller installs (classic ~124 MB → ~53 MB), a ~3× faster parser, an async load behind a progress indicator, and responsive editing (cut / paste / duplicate / move / enable-disable / select-all / sort no longer freeze on ~400K-entry files) in both editions. Also: the classic column-header sort no longer crashes on .NET 10; the modern edition gains a status bar (line + host-entry counts), flicker-free columns, and keeps your selection across Check/Uncheck & Duplicate; and both editions parse trailing-dot FQDN hostnames (e.g. Tailscale MagicDNS host.tailnet.ts.net.). See the full release notes.

What's new in v1.3.2: high-DPI polish and fixes — the classic edition is now PerMonitorV2 DPI-aware (crisp on 4K / scaled displays) with sharper toolbar icons; the taskbar icon renders unplated and the elevation prompt shows the app icon (both editions); the File menu sits above the toolbar again (classic); the modern edition gained the missing row keyboard shortcuts (Del, Ctrl+D, Alt+Arrow move, Ctrl+Alt+Arrow insert); and both editions now warn about unsaved changes on exit. See the full release notes.

What's new since v1.2.0: a new modern edition (WinUI 3) on the Microsoft Store, native ARM64 builds, a move to .NET 10 with self-contained deployment, on-demand elevation (the app no longer runs entirely as administrator), per-user data under %LocalAppData%\HostsFileEditor, Authenticode-signed binaries, and many correctness fixes to undo/redo, move, cut/copy/paste, import/export, and filtering.

Legacy — v1.2.0

The last .NET Framework 4.x release that runs on Windows 7 and 8: much smaller because it relies on the .NET Framework already built into Windows rath

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#c-sharphostseditorhostsfiletray

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具