{"id":244,"date":"2026-04-26T15:38:44","date_gmt":"2026-04-26T15:38:44","guid":{"rendered":"https:\/\/mydiyaddiction.com\/?page_id=244"},"modified":"2026-04-26T15:42:32","modified_gmt":"2026-04-26T15:42:32","slug":"resistor-color-code-calculator","status":"publish","type":"page","link":"https:\/\/mydiyaddiction.com\/?page_id=244","title":{"rendered":"Resistor Color Code Calculator"},"content":{"rendered":"<div class=\"entry\">\n\n\n<div style=\"max-width:900px;margin:auto;font-family:Arial,sans-serif;\">\n  <h3>This will work for Inductors too!<\/h3>\n\n  <label><strong>Select Mode:<\/strong><\/label>\n  <select id=\"mode\" onchange=\"changeMode()\">\n    <option value=\"4\">4 Band<\/option>\n    <option value=\"5\">5 Band<\/option>\n    <option value=\"6\">6 Band<\/option>\n  <\/select>\n\n  <!-- RESISTOR GRAPHIC -->\n  <div style=\"margin:20px 0;text-align:center;\">\n    <svg width=\"500\" height=\"120\" viewBox=\"0 0 500 120\">\n      <line x1=\"0\" y1=\"60\" x2=\"150\" y2=\"60\" stroke=\"#888\" stroke-width=\"6\"\/>\n      <line x1=\"350\" y1=\"60\" x2=\"500\" y2=\"60\" stroke=\"#888\" stroke-width=\"6\"\/>\n      <rect x=\"150\" y=\"30\" width=\"200\" height=\"60\" rx=\"20\" fill=\"#d2b48c\"\/>\n\n      <rect id=\"band1\" x=\"170\" y=\"30\" width=\"10\" height=\"60\"\/>\n      <rect id=\"band2\" x=\"190\" y=\"30\" width=\"10\" height=\"60\"\/>\n      <rect id=\"band3\" x=\"210\" y=\"30\" width=\"10\" height=\"60\"\/>\n      <rect id=\"band4\" x=\"250\" y=\"30\" width=\"10\" height=\"60\"\/>\n      <rect id=\"band5\" x=\"280\" y=\"30\" width=\"10\" height=\"60\"\/>\n      <rect id=\"band6\" x=\"310\" y=\"30\" width=\"10\" height=\"60\"\/>\n    <\/svg>\n  <\/div>\n\n  <hr>\n\n  <h3>Color \u2192 Value<\/h3>\n  <div id=\"bands\"><\/div>\n\n  <button onclick=\"calculate()\">Calculate<\/button>\n  <h3 id=\"result\"><\/h3>\n\n  <hr>\n\n  <h3>Reverse Lookup (Value \u2192 Colors)<\/h3>\n  <input type=\"number\" id=\"revValue\" placeholder=\"Enter resistance (ohms)\">\n  \n  <select id=\"revTolerance\">\n    <option value=\"1\">\u00b11%<\/option>\n    <option value=\"2\">\u00b12%<\/option>\n    <option value=\"5\" selected>\u00b15%<\/option>\n    <option value=\"10\">\u00b110%<\/option>\n  <\/select>\n\n  <button onclick=\"reverseLookup()\">Find Colors<\/button>\n  <h3 id=\"revResult\"><\/h3>\n<\/div>\n\n<script>\nconst colors = [\n  {name:\"Black\", digit:0, multiplier:1, tol:null, hex:\"#000\"},\n  {name:\"Brown\", digit:1, multiplier:10, tol:1, hex:\"#6B3F1D\"},\n  {name:\"Red\", digit:2, multiplier:100, tol:2, hex:\"#D32F2F\"},\n  {name:\"Orange\", digit:3, multiplier:1000, tol:null, hex:\"#F57C00\"},\n  {name:\"Yellow\", digit:4, multiplier:10000, tol:null, hex:\"#FBC02D\"},\n  {name:\"Green\", digit:5, multiplier:100000, tol:0.5, hex:\"#388E3C\"},\n  {name:\"Blue\", digit:6, multiplier:1000000, tol:0.25, hex:\"#1976D2\"},\n  {name:\"Violet\", digit:7, multiplier:10000000, tol:0.1, hex:\"#7B1FA2\"},\n  {name:\"Gray\", digit:8, multiplier:100000000, tol:0.05, hex:\"#757575\"},\n  {name:\"White\", digit:9, multiplier:1000000000, tol:null, hex:\"#fff\"},\n  {name:\"Gold\", digit:null, multiplier:0.1, tol:5, hex:\"#C9A227\"},\n  {name:\"Silver\", digit:null, multiplier:0.01, tol:10, hex:\"#C0C0C0\"}\n];\n\nlet lastReverseBands = null;\n\nfunction createSelectWithSwatch(id, type) {\n  let wrapper = document.createElement(\"div\");\n  wrapper.style.display = \"flex\";\n  wrapper.style.alignItems = \"center\";\n  wrapper.style.gap = \"10px\";\n  wrapper.style.marginBottom = \"8px\";\n\n  let label = document.createElement(\"span\");\n  label.textContent = id.toUpperCase() + \":\";\n\n  let swatch = document.createElement(\"div\");\n  swatch.style.width = \"30px\";\n  swatch.style.height = \"20px\";\n  swatch.style.border = \"1px solid #333\";\n\n  let sel = document.createElement(\"select\");\n  sel.id = id;\n\n  colors.forEach(c => {\n    if (type === \"digit\" && c.digit === null) return;\n    if (type === \"tol\" && c.tol === null) return;\n\n    let val = c[type];\n    let opt = document.createElement(\"option\");\n    opt.value = val;\n    opt.textContent = c.name;\n    sel.appendChild(opt);\n  });\n\n  sel.onchange = () => {\n    let c = colors.find(col => col[type] == sel.value);\n    if (c) {\n      swatch.style.background = c.hex;\n      updateGraphicFromSelectors();\n    }\n  };\n\n  wrapper.appendChild(label);\n  wrapper.appendChild(swatch);\n  wrapper.appendChild(sel);\n\n  setTimeout(() => sel.onchange(), 0);\n  return wrapper;\n}\n\nfunction changeMode() {\n  let mode = document.getElementById(\"mode\").value;\n  let container = document.getElementById(\"bands\");\n  container.innerHTML = \"\";\n\n  let digits = mode == 4 ? 2 : 3;\n\n  for (let i = 1; i <= digits; i++) {\n    container.appendChild(createSelectWithSwatch(\"b\"+i, \"digit\"));\n  }\n\n  container.appendChild(createSelectWithSwatch(\"mult\", \"multiplier\"));\n  container.appendChild(createSelectWithSwatch(\"tol\", \"tol\"));\n\n  updateGraphicFromSelectors();\n}\n\nfunction clearBands() {\n  for (let i = 1; i <= 6; i++) {\n    document.getElementById(\"band\"+i).setAttribute(\"fill\", \"transparent\");\n  }\n}\n\nfunction updateGraphicFromSelectors() {\n  clearBands();\n\n  let mode = document.getElementById(\"mode\").value;\n  let digits = mode == 4 ? 2 : 3;\n\n  for (let i = 1; i <= digits; i++) {\n    let val = document.getElementById(\"b\"+i)?.value;\n    let c = colors.find(col => col.digit == val);\n    if (c) document.getElementById(\"band\"+i).setAttribute(\"fill\", c.hex);\n  }\n\n  let multVal = document.getElementById(\"mult\")?.value;\n  let multColor = colors.find(c => c.multiplier == multVal);\n  if (multColor) document.getElementById(\"band4\").setAttribute(\"fill\", multColor.hex);\n\n  let tolVal = document.getElementById(\"tol\")?.value;\n  let tolColor = colors.find(c => c.tol == tolVal);\n  if (tolColor) document.getElementById(\"band5\").setAttribute(\"fill\", tolColor.hex);\n}\n\nfunction updateGraphicFromReverse(bands) {\n  clearBands();\n\n  bands.forEach((colorName, i) => {\n    let c = colors.find(col => col.name === colorName);\n    if (c) document.getElementById(\"band\"+(i+1)).setAttribute(\"fill\", c.hex);\n  });\n}\n\nfunction calculate() {\n  let mode = document.getElementById(\"mode\").value;\n  let digits = mode == 4 ? 2 : 3;\n\n  let value = \"\";\n  for (let i = 1; i <= digits; i++) {\n    value += document.getElementById(\"b\"+i).value;\n  }\n\n  let mult = document.getElementById(\"mult\").value;\n  let tol = document.getElementById(\"tol\").value;\n\n  let resistance = parseInt(value) * mult;\n\n  document.getElementById(\"result\").innerHTML =\n    format(resistance) + \" \u00b1\" + tol + \"%\";\n}\n\nfunction format(val) {\n  if (val >= 1e6) return (val\/1e6) + \" M\u03a9\";\n  if (val >= 1e3) return (val\/1e3) + \" k\u03a9\";\n  return val + \" \u03a9\";\n}\n\nfunction reverseLookup() {\n  let val = parseFloat(document.getElementById(\"revValue\").value);\n  let tol = document.getElementById(\"revTolerance\").value;\n\n  if (!val || val <= 0) {\n    document.getElementById(\"revResult\").innerHTML = \"Enter a valid value.\";\n    return;\n  }\n\n  let exponent = Math.floor(Math.log10(val));\n  let base = val \/ Math.pow(10, exponent);\n  let digits = Math.round(base * 10).toString().slice(0,3);\n\n  let digitColors = digits.split(\"\").map(d =>\n    colors.find(c => c.digit == d)?.name\n  );\n\n  let multColor = colors.find(c =>\n    c.multiplier == Math.pow(10, exponent - (digits.length -1))\n  )?.name;\n\n  let tolColor = colors.find(c => c.tol == tol)?.name;\n\n  let bands = [...digitColors, multColor, tolColor];\n\n  document.getElementById(\"revResult\").innerHTML =\n    \"Bands: \" + bands.join(\" | \");\n\n  updateGraphicFromReverse(bands);\n}\n\nchangeMode();\n<\/script>\n\n\n<\/div>","protected":false},"excerpt":{"rendered":"<p>This will work for Inductors too! Select Mode: 4 Band5 Band6 Band Color \u2192 Value Calculate Reverse Lookup (Value \u2192 Colors) \u00b11%\u00b12%\u00b15%\u00b110% Find Colors<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-244","page","type-page","status-publish"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Resistor Color Code Calculator - MyDiyAddiction<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mydiyaddiction.com\/?page_id=244\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Resistor Color Code Calculator - MyDiyAddiction\" \/>\n<meta property=\"og:description\" content=\"This will work for Inductors too! Select Mode: 4 Band5 Band6 Band Color \u2192 Value Calculate Reverse Lookup (Value \u2192 Colors) \u00b11%\u00b12%\u00b15%\u00b110% Find Colors\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mydiyaddiction.com\/?page_id=244\" \/>\n<meta property=\"og:site_name\" content=\"MyDiyAddiction\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-26T15:42:32+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/mydiyaddiction.com\\\/?page_id=244\",\"url\":\"https:\\\/\\\/mydiyaddiction.com\\\/?page_id=244\",\"name\":\"Resistor Color Code Calculator - MyDiyAddiction\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/mydiyaddiction.com\\\/#website\"},\"datePublished\":\"2026-04-26T15:38:44+00:00\",\"dateModified\":\"2026-04-26T15:42:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/mydiyaddiction.com\\\/?page_id=244#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/mydiyaddiction.com\\\/?page_id=244\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/mydiyaddiction.com\\\/?page_id=244#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/mydiyaddiction.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Resistor Color Code Calculator\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/mydiyaddiction.com\\\/#website\",\"url\":\"https:\\\/\\\/mydiyaddiction.com\\\/\",\"name\":\"MyDiyAddiction\",\"description\":\"It&#039;s not junk if you can make stuff with it!!\",\"publisher\":{\"@id\":\"https:\\\/\\\/mydiyaddiction.com\\\/#\\\/schema\\\/person\\\/720114934cb9a2b7ead12ee7075fc169\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/mydiyaddiction.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/mydiyaddiction.com\\\/#\\\/schema\\\/person\\\/720114934cb9a2b7ead12ee7075fc169\",\"name\":\"Jerry\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/mydiyaddiction.com\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/iusa_400x400.104616819_rhl1-e1776557367869.png\",\"url\":\"https:\\\/\\\/mydiyaddiction.com\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/iusa_400x400.104616819_rhl1-e1776557367869.png\",\"contentUrl\":\"https:\\\/\\\/mydiyaddiction.com\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/iusa_400x400.104616819_rhl1-e1776557367869.png\",\"width\":100,\"height\":100,\"caption\":\"Jerry\"},\"logo\":{\"@id\":\"https:\\\/\\\/mydiyaddiction.com\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/iusa_400x400.104616819_rhl1-e1776557367869.png\"},\"sameAs\":[\"http:\\\/\\\/mydiyaddiction.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Resistor Color Code Calculator - MyDiyAddiction","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mydiyaddiction.com\/?page_id=244","og_locale":"en_US","og_type":"article","og_title":"Resistor Color Code Calculator - MyDiyAddiction","og_description":"This will work for Inductors too! Select Mode: 4 Band5 Band6 Band Color \u2192 Value Calculate Reverse Lookup (Value \u2192 Colors) \u00b11%\u00b12%\u00b15%\u00b110% Find Colors","og_url":"https:\/\/mydiyaddiction.com\/?page_id=244","og_site_name":"MyDiyAddiction","article_modified_time":"2026-04-26T15:42:32+00:00","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/mydiyaddiction.com\/?page_id=244","url":"https:\/\/mydiyaddiction.com\/?page_id=244","name":"Resistor Color Code Calculator - MyDiyAddiction","isPartOf":{"@id":"https:\/\/mydiyaddiction.com\/#website"},"datePublished":"2026-04-26T15:38:44+00:00","dateModified":"2026-04-26T15:42:32+00:00","breadcrumb":{"@id":"https:\/\/mydiyaddiction.com\/?page_id=244#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mydiyaddiction.com\/?page_id=244"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/mydiyaddiction.com\/?page_id=244#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mydiyaddiction.com\/"},{"@type":"ListItem","position":2,"name":"Resistor Color Code Calculator"}]},{"@type":"WebSite","@id":"https:\/\/mydiyaddiction.com\/#website","url":"https:\/\/mydiyaddiction.com\/","name":"MyDiyAddiction","description":"It&#039;s not junk if you can make stuff with it!!","publisher":{"@id":"https:\/\/mydiyaddiction.com\/#\/schema\/person\/720114934cb9a2b7ead12ee7075fc169"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mydiyaddiction.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/mydiyaddiction.com\/#\/schema\/person\/720114934cb9a2b7ead12ee7075fc169","name":"Jerry","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mydiyaddiction.com\/wp-content\/uploads\/2026\/04\/iusa_400x400.104616819_rhl1-e1776557367869.png","url":"https:\/\/mydiyaddiction.com\/wp-content\/uploads\/2026\/04\/iusa_400x400.104616819_rhl1-e1776557367869.png","contentUrl":"https:\/\/mydiyaddiction.com\/wp-content\/uploads\/2026\/04\/iusa_400x400.104616819_rhl1-e1776557367869.png","width":100,"height":100,"caption":"Jerry"},"logo":{"@id":"https:\/\/mydiyaddiction.com\/wp-content\/uploads\/2026\/04\/iusa_400x400.104616819_rhl1-e1776557367869.png"},"sameAs":["http:\/\/mydiyaddiction.com"]}]}},"_links":{"self":[{"href":"https:\/\/mydiyaddiction.com\/index.php?rest_route=\/wp\/v2\/pages\/244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mydiyaddiction.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mydiyaddiction.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mydiyaddiction.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mydiyaddiction.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=244"}],"version-history":[{"count":8,"href":"https:\/\/mydiyaddiction.com\/index.php?rest_route=\/wp\/v2\/pages\/244\/revisions"}],"predecessor-version":[{"id":254,"href":"https:\/\/mydiyaddiction.com\/index.php?rest_route=\/wp\/v2\/pages\/244\/revisions\/254"}],"wp:attachment":[{"href":"https:\/\/mydiyaddiction.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}