Reference·X12 837P·N4
X12 837P Reference

X12 837P N4 Segment Guide: Fields, Format, and Testing Gotchas

Jul 28, 2026 · 5 min read

N3 gives you a street. N4 finishes the address. It's a short segment — three fields most people actually use — but it's also where a surprising number of synthetic test files quietly break, because city, state, and ZIP look independent on the page and aren't independent in reality.

Quick answer

N4 (Geographic Location) is the segment in an X12 837P claim that carries the city, state, and postal code for whatever address the preceding N3 segment started — typically the billing provider, the pay-to address, or the subscriber's address, depending on which loop the N4 sits inside.

The elements that actually matter in practice

N401 →
City Name — free-text city, no code list involved — see the dedicated page below
N402 →
State or Province Code — the standard two-letter postal abbreviation, must correspond to the city and ZIP in the same segment — see the dedicated page below
N403 →
Postal Code — ZIP or ZIP+4 for a US address, must be a valid code for the state given in N402 — see the dedicated page below

Example

Synthetic example Generated by Synthibase
N4*DENVER*CO*80202

A synthetic N4 for a billing provider address in Denver, Colorado, with a five-digit ZIP code. No real provider location.

Where this trips people up

Synthetic data generators that pick city, state, and ZIP from three separate random lists will happily produce an N4 with a Texas ZIP code attached to a Massachusetts state abbreviation. Humans skim past this instantly, but a claim scrubber or payer-side edit that cross-checks ZIP-to-state ranges will reject the claim outright — and if your test suite never generates that mismatch, you won't find the rejection logic gap until a real typo does the same thing in production. The safer approach is to generate N401-N403 as a single correlated address record, not three independent random fields.

What Is X12 837P? The Complete Guide
How to Validate X12 EDI Files Before Payer Submission
Generate address blocks that are internally consistent
Synthibase generates synthetic 837P files with N3/N4 address blocks where city, state, and ZIP always agree with each other — so your validation logic gets tested against realistic data, not random-field mismatches.
Start free trial →
This page is written independently by Synthibase for testing and informational purposes. It is not an official publication of HL7 International or X12/Washington Publishing Company, and is not a substitute for reviewing the official standard or your trading partner's companion guide. See our Terms of Service for full legal terms.