An EPANET .inp file is a plain text file that describes a water network in labelled sections, so any text editor can read and change it. This guide covers the common sections, units, editing, and why files fail between programs. The examples open in PipePilot, a browser workspace that runs the EPANET 2.3 engine and reads and writes standard .inp files.
How is an EPANET .inp file organised?
An .inp file is a list of sections, each starting with a bracketed keyword such as [PIPES] and followed by one line per object. The rules, from the EPANET 2.2 manual and engine source:
- Sections can come in any order, but a node or link must be defined in [JUNCTIONS], [RESERVOIRS], [TANKS], [PIPES], [PUMPS] or [VALVES] before another section refers to it, so put those first, after [TITLE].
- Items are separated by spaces or tabs.
- A semicolon starts a comment; the rest of the line is ignored.
- Keywords are not case sensitive, so Duration and DURATION both work. ID labels are: J1 and j1 are different nodes.
- An ID can be up to 31 characters, with no spaces or semicolons. The manual allows 255 characters on a line.
- An [END] line stops the reader.
This complete file for a small gravity zone in metric units runs as it stands:
[TITLE]
Small gravity zone, metric units
[JUNCTIONS]
;ID Elev Demand Pattern
J1 92 2.5 DAY
J2 88 1.5 DAY ;school offtake
[RESERVOIRS]
;ID Head
R1 120
[PIPES]
;ID Node1 Node2 Length Diam Roughness MinorLoss Status
P1 R1 J1 400 150 130 0 OPEN
P2 J1 J2 250 100 130 0 OPEN
[PATTERNS]
;ID Multipliers
DAY 0.6 0.9 1.4 1.1 0.8 0.5
[OPTIONS]
UNITS LPS
HEADLOSS H-W
[TIMES]
DURATION 24:00
PATTERN TIMESTEP 4:00
[COORDINATES]
;Node X-Coord Y-Coord
R1 0 0
J1 400 0
J2 400 250
[END]
What do the network sections hold?
Each network section holds one line per object with fields in a fixed order; optional trailing fields can be left out.
| Section | Fields in order |
|---|---|
| [TITLE] | Lines of text describing the project. Optional. |
| [JUNCTIONS] | ID, elevation, base demand, demand pattern ID. At least one junction is required. |
| [RESERVOIRS] | ID, head (elevation plus pressure head), head pattern ID. |
| [TANKS] | ID, bottom elevation, initial, minimum and maximum level, diameter, minimum volume, volume curve ID. |
| [PIPES] | ID, start node, end node, length, diameter, roughness, minor loss coefficient, status (OPEN, CLOSED or CV). |
| [PUMPS] | ID, start node, end node, then HEAD and a curve ID, or POWER and a value, plus optional SPEED and PATTERN. |
| [VALVES] | ID, start node, end node, diameter, type (PRV, PSV, PBV, FCV, TCV or GPV), setting, minor loss coefficient. |
| [DEMANDS] | Junction ID, base demand, pattern ID, and a category name after a semicolon. |
Check valves belong to pipes (status CV), not to [VALVES]. Lines in [DEMANDS] replace the [JUNCTIONS] demand for that junction, so one junction can carry several demand categories. Every network needs at least one reservoir or tank.
Where do patterns, curves and controls go?
Time patterns go in [PATTERNS], data curves in [CURVES], and operating rules in [CONTROLS] or [RULES].
[PATTERNS] lines give a pattern ID and its multipliers, and a long pattern continues on more lines with the same ID. All patterns share one time step, set in [TIMES], and wrap back to the start when the run is longer. Our guide to extended period simulation shows patterns driving a 24-hour run.
[CURVES] holds one X,Y point per line, each starting with the curve ID, in order of increasing X. A curve can be pump head or efficiency, tank volume, or GPV headloss. Windows EPANET reads a comment such as ;PUMP: Main pump set, directly above a curve's first point, as the curve's type and description. Our pump curves guide covers how EPANET reads pump curve points.
[CONTROLS] holds simple controls, one condition per line, such as LINK P2 CLOSED AT TIME 6 or LINK P2 OPEN IF NODE J2 BELOW 10, where the value is a junction pressure or a tank level. [RULES] holds rule-based controls that combine conditions; only RULE, IF and THEN are required. OR binds more tightly than AND, so IF A OR B AND C means IF (A OR B) AND C.
[RULES]
RULE NIGHT
IF SYSTEM CLOCKTIME >= 10 PM
OR SYSTEM CLOCKTIME < 5 AM
THEN PIPE P2 STATUS IS CLOSED
ELSE PIPE P2 STATUS IS OPEN
PRIORITY 1
What do [OPTIONS] and [TIMES] set?
[OPTIONS] sets the units and solver choices, and [TIMES] sets the run length and time steps. Every entry is optional. The EPANET 2.2 manual gives the defaults: UNITS GPM, HEADLOSS H-W (Hazen-Williams), DEMAND MODEL DDA, TRIALS 200 and ACCURACY 0.001. A DURATION of 0, the default, means a single snapshot.
How does the UNITS option decide the units in the file?
The UNITS line decides the units of every number in the file: with CFS, GPM, MGD, IMGD or AFD everything is US customary, and with LPS, LPM, MLD, CMH or CMD everything is metric.
| Quantity | US flow units | Metric flow units |
|---|---|---|
| Elevation, head, length | ft | m |
| Pipe diameter | in | mm |
| Pressure | psi | m |
| Darcy-Weisbach roughness | millifeet | mm |
Changing the UNITS line in a text editor converts nothing. The same numbers are read in the new units, so a 12 inch pipe becomes a 12 mm pipe.
What are [COORDINATES] for?
[COORDINATES] gives each node an X and Y position for drawing the map and has no effect on the hydraulics. Any unit and origin will do, and pipe lengths come from [PIPES], not from the distance between coordinates. Pipe bends go in [VERTICES].
How do you edit an .inp file by hand or with a script?
Edit the file in a plain text editor and run it again. Keep the dot as the decimal separator: the engine reads numbers with a dot whatever the computer's regional settings, so 92,5 is an illegal numeric value (error 202). Check this after a spreadsheet has saved the file. Rename an ID everywhere it appears, or pipes still using the old name give error 203, undefined node. Error 200 means the input has errors, and EPANET lists each bad line with its section.
A script can parse the text itself: read line by line, cut each line at the first semicolon, split on spaces and tabs, and track the current section. The alternative is the EPANET toolkit, the engine as a library: EN_open reads a file, functions such as EN_setlinkvalue change values, and EN_saveinpfile writes a new file.
That new file is not a copy of yours. The EPANET 2.3 writer moves junction demands into [DEMANDS], keeps only the first three title lines and writes every section even when empty. It keeps comments at the end of node and link lines and above each pattern or curve, and drops other comment lines.
Why do .inp files fail when they move between programs?
Most failures come from stricter rules or an older EPANET. Check these first:
| Problem | What happens | Fix |
|---|---|---|
| EPANET 2.3 file in the EPANET 2.2 engine | 2.3 adds a [LEAKAGE] section, a BACKFLOW ALLOWED option and CMS flow units. 2.2 stops at [LEAKAGE] with a syntax error (201) and rejects UNITS CMS (213). | Delete those lines and use a flow unit 2.2 knows. |
| Decimal commas | Error 202. | Use dots in numbers. |
| Long IDs from GIS | Over 31 characters gives error 252. | Shorten IDs; replace spaces with underscores. |
| Same ID twice | Error 215. All nodes share one ID list, so a junction and a tank cannot both be 1. | Rename one. |
| IDs changed in case | Undefined node (203) or link (204). | Keep IDs exactly as written. |
| A .net project file | This is the Windows program's own project format, not an input file. | In EPANET, use File > Export > Network. |
How do you check an .inp file in PipePilot?
Open it in PipePilot in the browser, using File > Open (Ctrl+O), which reads .inp files from EPANET or any program that writes the format. Project > Model Check flags IDs EPANET cannot save and diameters that look like inches in a metric model, and Report > Problems explains each error from the last run. PipePilot does not show the raw .inp text, so use a text editor for edits like those above. File > Save downloads the network as .inp. The Getting started and Fixing problems docs pages cover each step.
Jagadeesh Gaddam
CEO, Smart Bhujal
Try this in GeoPilot
Run the analysis described in this article with one prompt. No setup required.
Open GeoPilot