ASME B31.4 & B31.8 Pipeline Codes — The Complete Engineer’s Guide
ASME B31.4 and B31.8 are the two pipeline design codes that govern the safe transportation of liquid hydrocarbons and gas across the world’s transmission networks. Whether you are sizing a crude oil trunkline, qualifying a girth weld procedure on a gas export line, or reviewing a pressure test protocol, the applicable code is either B31.4 — for liquid and slurry service — or B31.8 — for gas transmission and distribution. Understanding which code applies, what the design equations demand, and how the welding and inspection requirements differ from process piping codes such as ASME B31.3 is essential knowledge for every pipeline engineer and inspector.
This guide covers both codes in depth: their scope and applicability boundaries, the hoop stress and wall thickness design formulas, B31.8 class location requirements, permitted materials (API 5L line pipe grades), welding qualification under API 1104, non-destructive examination requirements, hydrostatic and pneumatic testing criteria, and a worked design example comparing the two codes side by side. A built-in wall thickness calculator lets you verify your own pipeline designs against B31.4 and B31.8 directly below.
Pipeline Wall Thickness Calculator — B31.4 / B31.8
Calculate minimum wall thickness and allowable operating pressure for liquid and gas pipelines per ASME B31.4 and B31.8.
Note: This calculator applies the Barlow-derived design formulas from ASME B31.4 Clause 403.2.1 and ASME B31.8 Section 841.11. Results are indicative; always verify against the applicable edition of the code. Mill tolerance is absorbed within the design factor for both codes.
The ASME B31 Code Family — Where B31.4 and B31.8 Fit
ASME B31 is the umbrella standard for pressure piping, divided into sections based on service type. The most relevant sections for oil and gas engineers are B31.1 (power plant piping), B31.3 (process piping in refineries and chemical plants), B31.4 (liquid transportation pipelines), and B31.8 (gas transmission and distribution). Understanding the jurisdictional boundary between these codes prevents costly errors — applying the wrong code to a piping system can lead to under- or over-designed walls and incorrect examination requirements.
B31.3 — Piping within the fence of a refinery, chemical plant, terminal, or compressor station.
B31.4 — Cross-country and gathering pipelines transporting liquids and slurries.
B31.8 — Cross-country and distribution pipelines transporting gas (predominantly gaseous phase).
The fence-line or tie-in point of a facility is typically the handover boundary between B31.3 and B31.4 / B31.8.
The critical distinction from ASME B31.1 and B31.3 is that B31.4 and B31.8 are designed for long-distance cross-country operation, where cost optimisation over hundreds of kilometres dominates. Both codes use a percentage of the Specified Minimum Yield Strength (SMYS) as the design basis, rather than the fraction-of-UTS allowable stress approach used in B31.3. This yields more optimistic allowable stresses for the high-strength API 5L line pipe grades that are standard in pipeline construction.
ASME B31.4 — Liquid Pipeline Transportation Systems
Scope and Applicability
ASME B31.4 covers pipeline transportation systems for liquids and slurries. Its scope includes crude oil pipelines, refined petroleum product lines, liquefied petroleum gas (LPG) pipelines, anhydrous ammonia lines, carbon dioxide pipelines, and aqueous mineral slurry transportation. The code applies to all pipe, flanges, bolting, gaskets, valves, pressure relief devices, fittings, and other piping components and fabrications used in liquid service. It governs facilities from the pumping station outlet through to the receiving terminal, including all appurtenant above-ground and buried piping within those stations.
B31.4 does not apply to piping within a refinery, chemical plant, or LNG liquefaction facility — that is B31.3 territory. It also does not govern process piping within pumping or compressor stations themselves; the B31.4 / B31.3 boundary is typically the first isolation valve at the station fence.
B31.4 Wall Thickness Design Formula
The required pressure design wall thickness under B31.4 is derived from the modified Barlow equation specified in Clause 403.2.1. The allowable hoop stress is taken as a fraction of the Specified Minimum Yield Strength (SMYS) of the pipe material, scaled by the design factor and weld joint factor.
B31.4 Design Factor
The design factor (F) in B31.4 is generally fixed at 0.72 for standard main-line segments. This means the allowable hoop stress is 72% of SMYS, providing an effective safety margin above yield. The factor is reduced in specific situations:
| Location or Condition | Design Factor F | Rationale |
|---|---|---|
| Standard main-line (onshore) | 0.72 | Normal service, rural or open terrain |
| Compressor / pump station piping | 0.60 | Higher consequence, manned facility |
| Highway, road, or rail crossing (cased) | 0.60 | Higher consequence crossing |
| Navigable waterway (major river) crossing | 0.60 | Environmental and public safety risk |
| Pressure vessel connections, pump nozzles | 0.50 | High integrity requirement |
Worked Example — B31.4 Wall Thickness
ASME B31.8 — Gas Transmission and Distribution Systems
Scope and Applicability
ASME B31.8 covers the design, fabrication, installation, inspection, and testing of pipeline facilities used in the transmission and distribution of natural gas and other predominantly gaseous hydrocarbons. The scope includes gas transmission and gathering pipelines, gas compressor stations, metering and regulation stations, gas mains, and service lines extending from the pipeline to the customer meter outlet. It also covers offshore gathering and transmission pipelines connecting offshore production platforms to onshore terminals.
B31.8 Wall Thickness Design Formula
The wall thickness design formula in B31.8 Section 841.11 uses the same Barlow-derived equation as B31.4, but introduces two additional factors: the temperature derating factor T and the class-location-dependent design factor F.
Class Location — B31.8’s Population-Based Safety Factor
The most distinctive feature of B31.8 is the class location system, which mandates progressively thicker walls as pipelines pass through more densely populated areas. Class location is determined by counting the number of buildings intended for human occupancy within a 1-mile (1.6 km) sliding window centred on the pipeline route, extending 220 yards (200 m) either side of the centreline.
| Class Location | Building Count (per 1-mile window) |
Typical Environment | Design Factor F | Max Hoop Stress (% SMYS) |
|---|---|---|---|---|
| Class 1 — Div. 1 | ≤ 10 | Desert, farmland, wasteland | 0.72 | 72% |
| Class 1 — Div. 2 | ≤ 10 | Rural — tested to 1.25× MAOP | 0.80 | 80% (post-test only) |
| Class 2 | 10 – 46 | Fringe of towns, industrial areas | 0.60 | 60% |
| Class 3 | ≥ 46 | Suburban residential, schools, hospitals | 0.50 | 50% |
| Class 4 | Multi-storey buildings prevail | Urban, dense city areas | 0.40 | 40% |
Worked Example — B31.8 Wall Thickness (Class 3)
Materials — API 5L Line Pipe Grades
Both codes primarily reference API 5L Specification for Line Pipe as the governing material standard. API 5L defines two Product Specification Levels: PSL 1 (basic) and PSL 2 (enhanced chemical composition limits, impact testing, and dimensional controls). Offshore and high-consequence applications almost exclusively use PSL 2 pipe. The grade designation is based on SMYS in thousands of psi — X65 has SMYS of 65,000 psi (448 MPa).
| API 5L Grade | SMYS (MPa) | SMYS (psi) | SMTS (MPa) | Typical Application |
|---|---|---|---|---|
| Gr. B | 241 | 35,000 | 414 | Low-pressure gathering, distribution |
| X42 | 289 | 42,000 | 414 | Older trunk lines, repairs |
| X52 | 358 | 52,000 | 455 | Mid-pressure liquid lines |
| X60 | 413 | 60,000 | 517 | General transmission |
| X65 | 448 | 65,000 | 530 | Most common transmission grade |
| X70 | 483 | 70,000 | 565 | High-pressure trunklines |
| X80 | 552 | 80,000 | 620 | Ultra-high pressure, large diameter |
Higher strength grades reduce wall thickness for a given diameter and pressure, cutting steel tonnage and weight. However, X70 and X80 require tighter heat input control during welding to avoid HAZ softening — see the discussion of microstructural control in high-strength steels. Carbon equivalent (CE) compliance must be verified; use the carbon equivalent calculator to confirm preheat adequacy.
Welding Requirements — API 1104
Unlike process piping (B31.3 / B31.1), which references ASME Section IX for welding qualification, both B31.4 and B31.8 reference API 1104 — Welding of Pipelines and Related Facilities as the governing welding standard for field girth welds. API 1104 governs welding procedure specification (WPS) development and qualification, welder performance qualification, in-process inspection, radiographic testing procedures and acceptance criteria, and weld repair requirements.
API 1104 Welding Procedure Qualification
A welding procedure specification (WPS) under API 1104 must be qualified by a procedure qualification record (PQR) demonstrating satisfactory mechanical test results. Qualification tests include:
- Nick-break test — evaluates weld root and fill for internal soundness
- Tensile test — confirms weld tensile strength at least equals pipe SMYS
- Guided bend test — evaluates ductility and fusion of root and face
- Charpy V-notch impact test (when required by pipe specification or purchaser)
Essential variables in API 1104 WPS qualification include pipe grade and wall thickness range, joint design (bevel angle, root gap, root face), welding process, electrode/wire classification, shielding gas type and flow, direction of welding (downhill or uphill), and preheat range.
API 1104 NDT and Acceptance Criteria
API 1104 Section 9 specifies radiographic examination acceptance criteria. For production welds, radiographic testing is mandatory for the percentage of welds specified in the applicable code (B31.4 or B31.8) and the project specification. Acceptance criteria cover burn-through, incomplete fusion, incomplete penetration, internal concavity, slag inclusions, and porosity. For PAUT and TOFD used as alternatives to radiography, API 1104 Appendix A provides acceptance criteria — see the pipe wall thickness guide for context on how defect location relative to wall thickness influences fitness for service.
Examination and Testing Requirements
Non-Destructive Examination
Both B31.4 and B31.8 require radiographic examination or an acceptable alternative (PAUT, TOFD) for girth welds. The minimum radiography percentage depends on the code, class location (B31.8), and project specification. B31.8 Class 3 and 4 areas typically require 100% RT or UT of all girth welds. Lower class locations may permit spot radiography at a minimum of 10% of welds, though most operators specify higher percentages on high-pressure lines.
Hydrostatic Test Requirements
| Code | Test Medium | Minimum Test Pressure | Hold Duration |
|---|---|---|---|
| B31.4 | Water (preferred); hydrocarbons permitted | 1.25 × MOP (for all new pipelines) | Minimum 4 hours (pipelines); 1 hour (facility piping) |
| B31.8 Class 1 Div 1 | Water or gas | 1.10 × MAOP (gas test); 1.25 × MAOP (water test) | Minimum 8 hours |
| B31.8 Class 1 Div 2 | Water preferred | 1.25 × MAOP | Minimum 8 hours |
| B31.8 Class 2, 3, 4 | Water preferred | 1.25 × MAOP | Minimum 8 hours |
Key Code Comparison — B31.4 vs B31.8 vs B31.3
| Feature | ASME B31.4 (Liquid) | ASME B31.8 (Gas) | ASME B31.3 (Process) |
|---|---|---|---|
| Fluid service | Liquids, slurries | Gas (predominantly) | All process fluids |
| Design basis | % SMYS (F = 0.72) | % SMYS (F = 0.40–0.72) | Fraction of UTS or yield |
| Safety factor / design factor | Fixed 0.72 | Class-dependent 0.40–0.72 | S = min(UTS/3, 2/3 yield) |
| Mill tolerance treatment | Absorbed in F | Absorbed in F | Explicit divide-by-(1-MT) |
| Welding qualification | API 1104 | API 1104 | ASME Section IX |
| Typical pipe material | API 5L line pipe | API 5L line pipe | ASTM A106, A53, A335 |
| Hydrostatic test | 1.25 × MOP, 4 hr | 1.10–1.25 × MAOP, 8 hr | 1.5 × design P (min 10 min) |
| Surge limit | 110% of MOP | Not applicable (gas) | 133% of design P (B31.3 App. F) |
| Population-based design factor | No | Yes (Class Location) | No |
For engineers moving between process piping and pipeline work, the most significant difference is the welding qualification standard: ASME Section IX qualifications do not automatically satisfy API 1104 requirements. A welder or welding procedure qualified under Section IX for B31.3 piping work must be separately qualified under API 1104 to work on B31.4 or B31.8 pipeline girth welds. Review the P-Number and F-Number guide to understand how material groupings differ between the two qualification systems.
DOT Regulatory Integration — 49 CFR Parts 192 and 195
In the United States, B31.4 and B31.8 are legally mandated through Department of Transportation regulations. 49 CFR Part 195 (Hazardous Liquid Pipelines) incorporates B31.4 by reference as the design basis for liquid pipelines. 49 CFR Part 192 (Gas Transmission and Distribution) incorporates B31.8 in the same manner for gas pipelines. The DOT regulations do not duplicate code requirements — they invoke the B31 codes as the minimum standard and add operational requirements such as cathodic protection, leak detection, and integrity management programmes.
Outside the United States, many jurisdictions adopt or adapt B31.4 and B31.8 directly, or use equivalent national standards such as CSA Z662 (Canada), AS 2885 (Australia), or EN 14161 (Europe). The design principles are consistent, though specific safety factors and test requirements may vary.
ASME B31.8S — Integrity Management
ASME B31.8S is a supplement to B31.8 that provides guidance on the integrity management of natural gas transmission pipelines. It defines methodologies for identifying threats (corrosion, mechanical damage, stress corrosion cracking), assessing risk, and establishing inspection intervals using ILI (in-line inspection) tools, pressure testing, and direct assessment techniques. B31.8S works alongside B31G (fitness-for-service assessment of corrosion defects) and ASME B31Q (pipeline personnel qualification). Understanding B31.8S is increasingly important as regulatory focus shifts toward pipeline safety in High Consequence Areas (HCAs).
Recommended Reference Books
ASME B31.4 Pipeline Transportation Code
Official ASME B31.4 code covering liquid and slurry pipeline design, construction, and maintenance requirements.
View on AmazonASME B31.8 Gas Transmission Code
Official ASME B31.8 standard for gas transmission and distribution piping systems design and operation.
View on AmazonAPI 1104 Welding of Pipelines
The definitive pipeline welding standard covering WPS qualification, welder certification, inspection, and acceptance criteria for girth welds.
View on AmazonPipeline Engineering & Design
Practical engineering reference covering pipeline hydraulics, wall thickness design, stress analysis, and cross-country pipeline construction practices.
View on AmazonDisclosure: WeldFabWorld participates in the Amazon Associates programme (StoreID: neha0fe8-21). If you purchase through these links, we may earn a small commission at no extra cost to you. This helps support free technical content on this site.
Frequently Asked Questions
What is the difference between ASME B31.4 and B31.8?
ASME B31.4 governs liquid and slurry pipeline transportation systems — including crude oil, refined petroleum products, LPG, anhydrous ammonia, carbon dioxide, and aqueous mineral slurries. ASME B31.8 governs gas transmission and distribution piping systems transporting products that are predominantly in the gaseous phase, including natural gas, sour gas, and LNG vapour.
The key design difference is that B31.4 uses a fixed design factor (F = 0.72 for main lines), while B31.8 uses a variable design factor (0.72, 0.60, 0.50, or 0.40) tied to class location based on population density near the pipeline route. Both codes reference B31.3 as the boundary code for piping within processing facilities.
What is the hoop stress formula used in ASME B31.4 and B31.8?
Both codes derive required wall thickness from the Barlow equation modified by code-specific safety factors. In B31.4: t = (P × D) / (2 × S), where S = F × E × SMYS (F = 0.72, E = weld joint factor). In B31.8: t = (P × D) / (2 × SMYS × F × E × T), where F is the class location design factor, E is the longitudinal joint factor, and T is the temperature derating factor (1.0 below 121°C / 250°F).
Both formulas use the outside diameter D, making them conservative compared to mean-diameter methods. The calculator at the top of this page implements both formulas with step-by-step workings. For process piping, compare with the B31.3 / B31.1 wall thickness calculator.
What are ASME B31.8 class locations and how do they affect design?
Class locations categorise pipeline route sections by population density using a 1-mile (1.6 km) sliding window, counting buildings intended for human occupancy within 220 yards either side. Class 1 (≤ 10 buildings) permits F = 0.72; Class 2 (10–46 buildings) requires F = 0.60; Class 3 (≥ 46 buildings, schools, hospitals) requires F = 0.50; Class 4 (multi-storey buildings prevail) requires F = 0.40.
A lower design factor mandates a thicker pipe wall. If development near an existing pipeline causes a class upgrade, the operator must pressure-test the segment at the new class test pressure, reduce the MAOP, or replace the pipe. This is a significant lifecycle cost consideration for pipelines designed close to populated areas.
Does ASME B31.4 or B31.8 govern pipeline welding, or does API 1104 apply?
Both ASME B31.4 and B31.8 reference API 1104 (Welding of Pipelines and Related Facilities) as the governing welding standard for pipeline girth welds. API 1104 covers WPS qualification, welder performance qualification, radiographic and ultrasonic examination, and acceptance criteria for pipeline field joints. ASME Section IX qualifications are not automatically transferable to pipeline work.
Facility piping attached to the pipeline — within compressor stations, metering stations — may revert to ASME Section IX under B31.3 jurisdiction, depending on the tie-in point. For SMAW electrode selection on pipeline girth welds, cellulosic E6010 is standard for root passes in downhill welding, with E7018 fill and cap for uphill or when low-hydrogen deposits are required.
What materials are permitted under ASME B31.4 and B31.8?
The primary line pipe material for both codes is API 5L specification steel, from Gr. B (SMYS 241 MPa) through X42, X52, X60, X65, X70, and X80. Higher strength grades allow thinner walls for the same design pressure. PSL 2 pipe is preferred for high-consequence and offshore applications, offering tighter chemical composition controls, mandatory impact testing, and tighter dimensional tolerances.
Both codes also permit ASTM A53, A106, and A333 for specific applications. For sour service lines (H2S-containing fluids), use API 5L PSL 2 sour service pipe conforming to NACE MR0175 / ISO 15156 hardness and composition requirements. Review the sour service guide for detailed requirements.
What are the hydrostatic test pressure requirements for B31.4 and B31.8 pipelines?
Under ASME B31.4, the hydrostatic test pressure must be at least 1.25 times the MOP, held for a minimum of 4 hours for pipelines. Under ASME B31.8, Class 1 Division 1 permits a gas strength test at 1.10 × MAOP; all other class locations require 1.25 × MAOP as the minimum test pressure, held for 8 hours. Water is the preferred test medium for both codes.
B31.4 also limits surge pressures to 110% of MOP, which requires surge analysis and mitigation for liquid pipelines. B31.3 process piping uses a higher test factor of 1.5 × design pressure, reflecting its more conservative allowable stress basis and the greater variety of fluid services covered. See the comparison with B31.1 vs B31.3 testing requirements for further context.
Is PWHT required for pipeline welds under B31.4 or B31.8?
PWHT is not routinely required for most pipeline welds under B31.4 and B31.8. Pipeline construction typically involves API 5L carbon steel grades where PWHT is not mandatory, provided the welding procedure controls preheat and interpass temperature appropriately. For sour service or high-strength (X70, X80) grades, preheat is critical to limit HAZ hardness below 250 HV, which effectively reduces the need for PWHT in most cases.
For P91 and other alloy steels used in compressor station facility piping (governed by B31.3), full PWHT is mandatory — see the P91 welding guide. Thermal cycle effects on microstructure must always be considered when specifying heat treatment for higher-alloy pipeline components.
How does the B31.8 design factor differ for offshore versus onshore pipelines?
For onshore pipelines, B31.8 ties the design factor to class location (0.72 down to 0.40). For offshore gathering and transmission pipelines, B31.8 Chapter VIII applies, typically permitting F = 0.72. However, many offshore pipeline projects in international jurisdictions use DNV-ST-F101 (Submarine Pipeline Systems), which employs a limit-state design philosophy with separate checks for pressure containment, local buckling, and fatigue — a fundamentally different approach from the permissible-stress basis of B31.8.
Engineers working on offshore projects should confirm which code the project specification mandates before proceeding. DNV-ST-F101 may allow thinner walls in some loading scenarios but imposes additional reeling, installation, and on-bottom stability checks that B31.8 does not address. For corrosion assessment of existing offshore lines, B31G and API 579 are the relevant fitness-for-service tools.