File format · .haz

HAZ File Recovery — Microsoft Train Simulator Hazard Files

HAZ files define hazard data for Microsoft Train Simulator routes. Learn what they contain, why they fail to load, and how to repair corrupt .haz files.


Microsoft Train Simulator, released by Microsoft in 2001, remains one of the most enduring rail simulation platforms ever produced. Its longevity is due in large part to a vibrant modding community that continues to build custom routes, activities, rolling stock, and scenery more than two decades after the software shipped. One of the lesser-known file types powering that ecosystem is the HAZ file — the Train Simulator Hazard File — which stores hazard definitions referenced by route and activity data.

What a HAZ file is and what uses it

A .haz file is a data file used by Microsoft Train Simulator (MSTS) to define a hazard object placed along a route. Hazards are scenery or trackside elements that can trigger an event — typically a derailment or an activity failure — when a player's train collides with them or passes through their defined area. Common examples include landslides, fallen rocks, stalled vehicles at grade crossings, or debris on the rails. Activity designers use hazards to create scripted incidents that the player must avoid, adding challenge and narrative to a scenario.

HAZ files are not standalone objects. They work in concert with several other MSTS file types:

  • .w files — the world or tile files that make up the route's geography and place objects in 3D space.
  • .s files — shape files that define the 3D geometry of the hazard object itself.
  • .ace files — the texture images applied to the shape.
  • .act files — activity files that may reference hazards as part of scenario events.
  • .ref files — reference files used by the Route Editor to list available objects for placement.

When a route designer places a hazard in the Route Editor, the simulator creates or updates a .haz file describing the hazard's properties and links it to the relevant shape and world data. At runtime, MSTS reads the HAZ file to determine collision parameters and what event should fire on contact.

Structure and technical details

The HAZ file is a proprietary, binary or semi-structured data format owned by Microsoft Corporation as part of the Train Simulator codebase. Microsoft never published a formal public specification for the format, so much of what is known about its internal structure comes from community reverse-engineering efforts and the work of tools developers in the MSTS modding scene.

What the community has established is that a typical HAZ file contains:

  • A header identifying the file type and version.
  • References (by filename) to the shape (.s) file that represents the hazard visually.
  • A bounding-region definition — the volume or area within which contact triggers the hazard event.
  • Event or outcome data describing what happens when the hazard is triggered (for example, a derailment).

Because Microsoft did not release official documentation, we treat the vendor's original code and any surviving official help files as authoritative on points of format behaviour. Where community findings and official sources diverge, the official material takes precedence.

Why HAZ files become corrupt or unreadable

HAZ files are small and relatively simple, which makes the causes of corruption fairly narrow but no less disruptive when they strike. The most common scenarios we see are:

  • Incomplete writes during a crash. If MSTS or the Route Editor freezes or is force-closed while saving a tile or activity, the HAZ file may be truncated — cut off mid-record with no proper terminator.
  • Disk or filesystem errors. Bad sectors, failing drives, or filesystem corruption can damage the bytes that make up the file, rendering the header or body unreadable.
  • Improper editing. Modders who open .haz files in hex editors or unsupported third-party tools and save changes incorrectly can break the internal structure — for example, by altering offset values or leaving string references unterminated.
  • Broken cross-references. A HAZ file may be intact internally but point to a shape (.s) or texture (.ace) file that has been deleted, renamed, or moved. MSTS will report an error loading the hazard even though the HAZ file itself is not byte-corrupt.
  • Encoding or transfer damage. Copying files between systems with different locale settings, or uploading and downloading through tools that alter line endings or byte order, can subtly damage binary data.
  • Malware or antivirus quarantine. Because .haz is an uncommon extension, overly aggressive antivirus software occasionally flags and quarantines these files, effectively removing them from the route.

What data can be recovered

In most cases, the recoverable content of a HAZ file falls into two categories:

  1. Internal data — the hazard's own properties, including its shape reference, bounding area, and event definition. If the file is truncated or partially corrupted, we can often salvage the intact portion and reconstruct the damaged records based on the patterns established by the readable sections.
  2. Relationship data — the links between the hazard and the rest of the route. Even when a HAZ file is severely damaged, we can determine which world tile, activity, and shape files it belonged to and help restore the connections so the route loads again.

If the original HAZ file is beyond salvage — for example, if it has been overwritten with zeroes — we may still be able to rebuild a functionally equivalent file by analysing the route's world files and activity definitions, which often retain enough information to infer what the hazard was and where it was placed.

How HAZ recovery works

Our recovery process for .haz files follows a structured approach:

  1. Evaluation. We examine the damaged file at the byte level to determine what is intact and what is corrupted. This includes checking the header, scanning for valid record structures, and identifying the point of failure.
  2. Cross-reference audit. We check the surrounding route files — world tiles, activities, shape files, and the route's .ref file — to understand the hazard's intended context and confirm whether the problem is internal corruption or a broken reference.
  3. Repair or reconstruction. Where the original data is recoverable, we repair the damaged structures directly. Where it is not, we reconstruct the file using inferred data from related files, preserving as much of the original design intent as possible.
  4. Validation. We verify the repaired file against the expected structure and, where feasible, confirm that it will be accepted by MSTS or the relevant editing tools.
  5. Return. We deliver the recovered file along with a report describing what was found, what was repaired, and any recommendations for preventing recurrence.

FAQ

What programs open HAZ files?

HAZ files are used exclusively by Microsoft Train Simulator. They are not meant to be opened directly by the user; the simulator reads them automatically when loading a route or activity. Modders sometimes inspect them with hex editors or specialised community-built MSTS utilities.

Can I delete a HAZ file if a route will not load?

Deleting a .haz file may allow the route to load, but any activity that depends on that hazard will no longer function correctly. It is better to repair or reconstruct the file than to remove it.

Are HAZ files used by Train Simulator 202x or Open Rails?

The .haz format is specific to the original Microsoft Train Simulator (2001). Open Rails, the modern open-source simulator that runs MSTS content, has its own object and event handling and may interpret or ignore MSTS hazard data differently. If you are running content under Open Rails and encounter HAZ-related errors, the issue may be compatibility rather than corruption.

How big are HAZ files typically?

They are very small — usually only a few hundred bytes to a few kilobytes. Their small size is an advantage for recovery, as there is less data to reconstruct, but it also means that even a few corrupted bytes can render the entire file unusable.

Can a corrupt HAZ file damage my route?

Not directly. A damaged .haz file will typically cause MSTS to report an error and refuse to load the affected tile or activity, but it will not corrupt other route files. However, repeated attempts to load a failing route while other files are being edited can lead to further save errors, so it is best to resolve HAZ problems promptly.


If you have a corrupt or unreadable .haz file — or an MSTS route that will not load because of a hazard error — send it to us for a free, no-obligation evaluation. Our recovery engineers will assess the damage and tell you exactly what can be recovered before you pay anything. There is no charge if we cannot recover your data.

Send us your .haz file for a free evaluation

Our recovery engineers will tell you exactly what can be recovered — at no cost. There is no charge if we cannot recover your data.

Start a free evaluation