Reference·N4 Segment·N402
X12 270/271 Reference

X12 270/271 N402 (State or Province Code): Format, Values, and Testing Notes

Jul 28, 2026 · 4 min read
← N401 N403 →

N402 is only two characters, so it's easy to assume there's nothing to test — but those two characters are the piece that ties a city name to the right postal code, and the segment does nothing to enforce that connection for you.

Quick answer

N402 is the second element of the N4 segment in an X12 271 response — a coded field that carries the two-letter state or province abbreviation for the address described by the surrounding N3 and N4 segments.

What this element carries

Format
Two-letter code — standard US state abbreviations, or equivalent province codes outside the US
Pairs with
N401 and N403 — together the three elements should describe one coherent, real location
Requirement
Required with N4 — must be populated whenever the N4 segment is used for a domestic address

Example

Synthetic example Generated by Synthibase
N4*Bellhaven*OH*43215

N402 = OH, the state code that should be consistent with both the city in N401 and the ZIP code range in N403. Synthetic 271 response data.

Where this trips people up

Because N402 is validated as a code value on its own — is it a real two-letter abbreviation — rather than against the other two address elements, a file can pass segment-level validation while pairing a legitimate state code with a city or ZIP from an entirely different state. Systems that stop checking once the code format looks correct never catch this, and the inconsistency only surfaces when a downstream address-verification service rejects the combination.

Testing X12 270/271 N4: The Fields Your System Actually Needs to Handle
How to Test 270/271 Eligibility Transactions Before Go-Live
How to Validate X12 EDI Files Before Payer Submission
Test address consistency, not just field format
Synthibase generates synthetic 271 responses with geographically matched N401, N402, and N403 values, so address-consistency checks get tested against realistic, coherent data, zero PHI.
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.