A PowerShell parser and technical documentation for the .red file format used by Midnight Club 2's in-game Race Editor. Each .red file is a fixed-size 222-byte binary file describing one custom race - including city, time of day, weather, race mode, CPU opponents, checkpoints, time bonuses, and lap count.
- Make a backup of your
/userdatafolder, just in case. - Place the parser scripts in the root of your Midnight Club 2 directory.
- Execute ParseRedToJson.ps1 to parse your
/userdata/*.redfiles to/userjson/*.jsonfiles. - Inspect the
.jsonfiles and make edits where wanted. Be sure to follow the specs for valid values. - Execute ParseJsonToRed.ps1 to parse the
/userjson/*.jsonfiles back to/userdata/*.redfiles.
The scripts in src/ are the source of truth. They reference src/race.schema.json at runtime for all enum data and validation. Do not edit the files in dist/ directly — they are generated.
Workflow:
- Edit the source scripts in
src/or the schema insrc/race.schema.json. - Run the build to produce standalone distributable scripts:
Tip: The Run selected PowerShell script VS Code extension lets you right-click any
pwsh .\dev\Build.ps1
.ps1file in the Explorer and run it directly, without needing a terminal. - The built scripts are written to
dist/. These have the schema inlined and are minified — share these with end users.
The build step inlines the schema as a here-string and strips all comments and blank lines from the output.
| File | Description |
|---|---|
src/ParseRedToJson.ps1 |
Reads all .red files from /userdata and writes one .json per file to /userjson. |
src/ParseJsonToRed.ps1 |
Validates and reads all .json files from /userjson and writes one .red per file to /userdata. |
src/race.schema.json |
JSON Schema (Draft 2020-12) for the race JSON format. Single source of truth for all enum data; the parser reads its lookup tables directly from this file. |
dev/Build.ps1 |
Inlines the schema into each source script and writes standalone output scripts to dist/. |
docs/RedFileFormat.md |
Full technical documentation of the .red binary format: byte map, enumerations, checkpoint layout, parsing rules, serialization rules, and padding sentinels. |
docs/PowershellNotes.md |
Notes and constraints for letting Github Copilot run PowerShell scripts in VS Code. |