Dev.to WebDev 🛠 Dev 👁 0 📖 4 min read

Automating NEC 210.52 Residential Electrical Outlet Spacing, Kitchen Counter Circuits, and GFCI/AFCI Rules in TypeScript

Rough-in electrical inspections fail more often on receptacle spacing geometry than on almost any other residential code item. A single 30"-wide wall section between a patio door and a corner left without a duplex outlet

Rough-in electrical inspections fail more often on receptacle spacing geometry than on almost any other residential code item. A single 30"-wide wall section between a patio door and a corner left without a duplex outlet violates NEC 210.52(A)(2), and a 50" stretch of kitchen countertop without a GFCI receptacle violates NEC 210.52(C)(1) — forcing costly drywall cuts after insulation and framing are already closed up.

In PlanCaliber, our free NEC 210.52 Electrical Outlet Placement Calculator and automatic Sheet E-101 Electrical Plans (E-POWR AutoCAD layer) compute exact minimum receptacle counts, 6-ft/12-ft wall spacing, 24-in/48-in kitchen countertop spans, and required 15A/20A GFCI and AFCI branch circuits. Here is the clean deterministic TypeScript engine behind it.

1. NEC 2023 Article 210.52 Residential Spacing Rules at a Glance

Room / Zone NEC Reference Max Edge Distance Max On-Center Spacing Min Wall / Counter Trigger Protection & Circuit
Living, Bedroom, Office Walls 210.52(A) 6'-0" (72") 12'-0" (144") Any wall >= 2'-0" (24") AFCI (15A or 20A)
Kitchen Countertops 210.52(C)(1) 24" (2'-0") 48" (4'-0") Any counter >= 12" wide GFCI + AFCI, min 2 × 20A small-appliance circuits
Bathrooms 210.52(D) 36" from outside edge of each basin 1 per basin Every sink basin 20A GFCI dedicated bathroom circuit
Garages (Attached/Detached) 210.52(G)(1) 1 per vehicle bay <= 5'-6" above floor Each car bay 20A GFCI dedicated garage circuit
Unfinished / Finished Basements 210.52(G)(3) & (A) 6'-0" in habitable finished rooms 12'-0" in finished zones >= 1 GFCI in unfinished utility area GFCI (unfinished) + AFCI (habitable)

2. TypeScript NEC 210.52 Wall & Countertop Receptacle Solver

Every continuous wall segment between doorways, fireplaces, or floor-to-ceiling openings is treated independently. On a wall of length L feet (L >= 2), no point along the floor line may be more than 6'-0" from an outlet — which yields Math.max(1, Math.ceil(L / 12)) outlets cleanly centered across the run (for example, a 14'-0" unbroken wall requires 2 outlets because 1 centered outlet leaves 7'-0" > 6'-0" at each corner!):

export type NecRoomType = 'living_bedroom' | 'kitchen' | 'bathroom' | 'garage' | 'basement';

export interface NecRoomInput {
  roomType: NecRoomType;
  wallSegmentsFt: number[];       // unbroken floor-line wall runs between doors/openings
  counterSegmentsIn?: number[];   // kitchen countertop wall runs in inches
  basins?: number;                // bathroom sink count
  garageBays?: number;            // vehicle bays (1-4)
  hasIslandCounter?: boolean;     // NEC 2023 210.52(C)(2): optional, or provision for future power
}

export interface NecRoomReport {
  wallOutlets: number;
  counterOutlets: number;
  dedicatedOutlets: number;
  totalDuplexOutlets: number;
  minBranchCircuits20A: number;
  protectionLabel: string;
  codeNotes: string[];
}

export function countWallOutletsNec21052A(wallSegmentsFt: number[]): number {
  return wallSegmentsFt.reduce((sum, lenFt) => {
    if (lenFt < 2) return sum; // walls < 24" wide are exempt
    return sum + Math.max(1, Math.ceil(lenFt / 12));
  }, 0);
}

export function countCounterOutletsNec21052C(counterSegmentsIn: number[]): number {
  return counterSegmentsIn.reduce((sum, spanIn) => {
    if (spanIn < 12) return sum; // countertop spans < 12" are exempt
    return sum + Math.max(1, Math.ceil(spanIn / 48));
  }, 0);
}

export function evaluateNec21052Room(input: NecRoomInput): NecRoomReport {
  const codeNotes: string[] = [];

  if (input.roomType === 'kitchen') {
    const wallOutlets = countWallOutletsNec21052A(input.wallSegmentsFt);
    const counterOutlets = countCounterOutletsNec21052C(input.counterSegmentsIn ?? []);
    if (input.hasIslandCounter) {
      codeNotes.push(
        'NEC 2023 210.52(C)(2): Island/peninsula receptacles are no longer mandatory, but if omitted, run wiring provisions for future installation (and never mount outlets below the countertop lip).'
      );
    }
    return {
      wallOutlets,
      counterOutlets,
      dedicatedOutlets: 0,
      totalDuplexOutlets: wallOutlets + counterOutlets,
      minBranchCircuits20A: 2,
      protectionLabel: 'GFCI + AFCI (20A Small-Appliance Circuits)',
      codeNotes,
    };
  }

  if (input.roomType === 'bathroom') {
    const basins = Math.max(1, Math.round(input.basins ?? 1));
    codeNotes.push('Mount at least one 20A GFCI receptacle within 36" of the outside edge of each basin (NEC 210.52(D)).');
    return {
      wallOutlets: 0,
      counterOutlets: 0,
      dedicatedOutlets: basins,
      totalDuplexOutlets: basins,
      minBranchCircuits20A: 1,
      protectionLabel: '20A GFCI Dedicated Bathroom Circuit',
      codeNotes,
    };
  }

  if (input.roomType === 'garage') {
    const bays = Math.max(1, Math.round(input.garageBays ?? 2));
    codeNotes.push('Install at least one 20A GFCI receptacle per vehicle bay, max 5\'-6" above finished floor (NEC 210.52(G)(1)).');
    return {
      wallOutlets: 0,
      counterOutlets: 0,
      dedicatedOutlets: bays,
      totalDuplexOutlets: bays,
      minBranchCircuits20A: 1,
      protectionLabel: '20A GFCI Dedicated Garage Circuit',
      codeNotes,
    };
  }

  const wallOutlets = countWallOutletsNec21052A(input.wallSegmentsFt);
  const protectionLabel =
    input.roomType === 'basement'
      ? 'GFCI (Unfinished) + AFCI (Finished Habitable Zones)'
      : 'AFCI Protected (15A or 20A Branch Circuit)';
  return {
    wallOutlets,
    counterOutlets: 0,
    dedicatedOutlets: 0,
    totalDuplexOutlets: wallOutlets,
    minBranchCircuits20A: Math.max(1, Math.ceil(wallOutlets / 10)),
    protectionLabel,
    codeNotes,
  };
}

3. Plot Your Outlets Live & Export Sheet E-101 + AutoCAD E-POWR Free to Draft

Run your exact kitchen, bedroom, bathroom, garage, or basement wall dimensions in our free NEC 210.52 Electrical Outlet Placement Calculator, then click straight into the PlanCaliber 2D/3D Studio or start from our Kitchen Island Remodel Template or Finished Basement Rec Room Template.

Drafting, AI sketch/PDF tracing, and watermarked proof PNG exports are free; clean unwatermarked Sheet A-101 + M-101 vector PDFs start at $9 one-time, and the $19 Full CAD Pack unlocks dedicated Sheet E-101 Electrical Plans (1/4"=1'-0"), layered AutoCAD R12 .DXF (including dedicated layer E-POWR, ACI Yellow), 3D .OBJ/.MTL, and framing/material .CSV takeoffs. PlanCaliber outputs are preliminary space-planning references; always verify electrical layouts, panel load calculations, and local NEC edition amendments with a licensed electrician.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.