{
  "id": "carpet",
  "version": "08aae345eb1f",
  "status": "published",
  "name": "Carpet Calculator",
  "question": "How much carpet do I need?",
  "summary": "Carpet calculator: how many square yards and linear feet of carpet to buy for a room, cut in whole strips from a 12 or 15 ft roll, with the seams, the leftover and the cost.",
  "category": "construction",
  "subcategory": "flooring",
  "url": "https://www.acalculator.org/construction/carpet-calculator",
  "markdown": "https://www.acalculator.org/construction/carpet-calculator.md",
  "kind": "function",
  "method": "Strips = room side across the strips ÷ roll width, rounded up; carpet to buy = strips × strip length × roll width, for the direction that buys less.",
  "assumptions": [
    "The room is a rectangle; split an L-shaped room into rectangles.",
    "Strips are full roll width and run the full length or width of the room; a cut-off piece is not reused to fill another gap.",
    "Add a few inches per strip for trimming at the walls if your fitter asks for it."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "l": {
        "title": "Room length",
        "description": "The longer side of the room, wall to wall.",
        "type": [
          "number",
          "string"
        ],
        "x-quantity": "length",
        "minimum": 0.01,
        "maximum": 1000
      },
      "w": {
        "title": "Room width",
        "description": "The shorter side of the room, wall to wall.",
        "type": [
          "number",
          "string"
        ],
        "x-quantity": "length",
        "minimum": 0.01,
        "maximum": 1000
      },
      "r": {
        "title": "Roll width",
        "description": "The width of the carpet roll.",
        "type": "string",
        "enum": [
          "12ft",
          "15ft",
          "4m",
          "5m",
          "custom"
        ]
      },
      "rw": {
        "title": "Custom roll width",
        "description": "The width of the roll, if not listed.",
        "type": [
          "number",
          "string"
        ],
        "x-quantity": "length",
        "minimum": 0.01,
        "maximum": 1000
      },
      "p": {
        "title": "Price per square yard",
        "description": "The price of the carpet per square yard, with pad and fitting if you like. Leave empty to skip.",
        "type": "number",
        "x-unit": "USD",
        "minimum": 0,
        "maximum": 1000000
      }
    }
  },
  "outputs": {
    "buy": {
      "label": "Carpet to buy",
      "description": "Strips × strip length × roll width.",
      "format": "quantity",
      "unit": "yd2"
    },
    "linear": {
      "label": "Length off the roll",
      "description": "Strips × strip length, the length cut from the roll.",
      "format": "quantity",
      "unit": "ft"
    },
    "strips": {
      "label": "Strips",
      "description": "Whole roll widths side by side.",
      "format": "integer"
    },
    "seams": {
      "label": "Seams",
      "description": "Strips − 1.",
      "format": "integer"
    },
    "layout": {
      "label": "Strips run",
      "description": "Which way the strips run.",
      "format": "text"
    },
    "room": {
      "label": "Room area",
      "description": "Room length × width.",
      "format": "quantity",
      "unit": "yd2"
    },
    "roomFeet": {
      "label": "Room area, square feet",
      "description": "Room length × width in square feet.",
      "format": "quantity",
      "unit": "ft2"
    },
    "leftover": {
      "label": "Leftover",
      "description": "Carpet to buy − room area.",
      "format": "quantity",
      "unit": "yd2"
    },
    "cost": {
      "label": "Cost",
      "description": "Carpet to buy in square yards × the price.",
      "format": "money"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "l": 4.572,
      "w": 3.9624,
      "r": "12ft",
      "rw": 3.6576000000000004
    },
    "outputs": {
      "buy": 28.98574848,
      "linear": 7.9248,
      "strips": 2,
      "seams": 1,
      "layout": "Along the room width",
      "room": 18.1160928,
      "roomFeet": 18.1160928,
      "leftover": 10.86965568
    },
    "text": "Buy 34.67 yd² of carpet, 26 ft off the roll."
  },
  "examples": [
    {
      "given": {
        "l": 4.572,
        "w": 3.9624,
        "r": "12ft",
        "p": 30
      },
      "expect": {
        "strips": 2,
        "buy": 28.98574848,
        "linear": 7.9248,
        "cost": 1040,
        "layout": "Along the room width"
      },
      "source": "Wikipedia, Carpet (carpets are commonly made 12 or 15 ft wide in the US and 4 or 5 m in Europe), https://en.wikipedia.org/wiki/Carpet (retrieved 2026-10-03); hand calculation in content.mdx: along the length 2 strips × 15 ft × 12 = 360 ft²; along the width 2 × 13 × 12 = 312 ft² = 34.67 yd², the smaller; × $30 = $1,040",
      "tolerance": 1e-12
    },
    {
      "given": {
        "l": 6.096,
        "w": 3.6576000000000004,
        "r": "12ft"
      },
      "expect": {
        "strips": 1,
        "seams": 0,
        "buy": 22.296729600000003,
        "leftover": 0
      },
      "source": "Wikipedia, Carpet (carpets are commonly made 12 or 15 ft wide in the US and 4 or 5 m in Europe), https://en.wikipedia.org/wiki/Carpet (retrieved 2026-10-03); hand calculation in content.mdx: 12 ÷ 12 = 1 strip × 20 ft = 240 ft² = 26.67 yd²",
      "tolerance": 1e-12
    },
    {
      "given": {
        "l": 6,
        "w": 4.5,
        "r": "4m"
      },
      "expect": {
        "strips": 2,
        "buy": 36,
        "room": 27,
        "leftover": 9
      },
      "source": "Wikipedia, Carpet (carpets are commonly made 12 or 15 ft wide in the US and 4 or 5 m in Europe), https://en.wikipedia.org/wiki/Carpet (retrieved 2026-10-03); hand calculation in content.mdx: along the length 2 × 6 × 4 = 48 m²; along the width 2 × 4.5 × 4 = 36 m²",
      "tolerance": 1e-12
    }
  ],
  "sources": [
    "Wikipedia, Carpet: carpets are commonly made in widths of 12 or 15 ft in the US and 4 or 5 m in Europe, retrieved 2026-10-03. https://en.wikipedia.org/wiki/Carpet",
    "NIST Special Publication 811 (2008), Appendix B: 1 ft = 0.3048 m exactly, 1 yd² = 9 ft² = 0.83612736 m², retrieved 2026-10-03. https://www.nist.gov/pml/special-publication-811"
  ],
  "related": [
    "square-yards",
    "flooring",
    "square-footage"
  ],
  "changelog": []
}
