<?xml version='1.0' encoding='utf-8'?>
<FilingSummary>
  <Version>3.22.2.2</Version>
  <ProcessingTime/>
  <ReportFormat>html</ReportFormat>
  <ContextCount>211</ContextCount>
  <ElementCount>333</ElementCount>
  <EntityCount>1</EntityCount>
  <FootnotesReported>false</FootnotesReported>
  <SegmentCount>59</SegmentCount>
  <ScenarioCount>0</ScenarioCount>
  <TuplesReported>false</TuplesReported>
  <UnitCount>13</UnitCount>
  <MyReports>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R1.htm</HtmlFileName>
      <LongName>0000001 - Document - Cover Page</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/CoverPage</Role>
      <ShortName>Cover Page</ShortName>
      <MenuCategory>Cover</MenuCategory>
      <Position>1</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R2.htm</HtmlFileName>
      <LongName>0000002 - Statement - Consolidated Statements of Operations</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/ConsolidatedStatementsofOperations</Role>
      <ShortName>Consolidated Statements of Operations</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>2</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R3.htm</HtmlFileName>
      <LongName>0000003 - Statement - Consolidated Statements of Comprehensive Income</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/ConsolidatedStatementsofComprehensiveIncome</Role>
      <ShortName>Consolidated Statements of Comprehensive Income</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>3</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R4.htm</HtmlFileName>
      <LongName>0000004 - Statement - Consolidated Statements of Comprehensive Income (Parenthetical)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/ConsolidatedStatementsofComprehensiveIncomeParenthetical</Role>
      <ShortName>Consolidated Statements of Comprehensive Income (Parenthetical)</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>4</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R5.htm</HtmlFileName>
      <LongName>0000005 - Statement - Consolidated Balance Sheets</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/ConsolidatedBalanceSheets</Role>
      <ShortName>Consolidated Balance Sheets</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>5</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R6.htm</HtmlFileName>
      <LongName>0000006 - Statement - Consolidated Balance Sheets (Parenthetical)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/ConsolidatedBalanceSheetsParenthetical</Role>
      <ShortName>Consolidated Balance Sheets (Parenthetical)</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>6</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R7.htm</HtmlFileName>
      <LongName>0000007 - Statement - Consolidated Statements of Cash Flows</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/ConsolidatedStatementsofCashFlows</Role>
      <ShortName>Consolidated Statements of Cash Flows</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>7</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R8.htm</HtmlFileName>
      <LongName>0000008 - Statement - Consolidated Statement of Shareholders' Equity</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/ConsolidatedStatementofShareholdersEquity</Role>
      <ShortName>Consolidated Statement of Shareholders' Equity</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>8</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R9.htm</HtmlFileName>
      <LongName>0000009 - Statement - Consolidated Statement of Shareholders' Equity (Parenthetical)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/ConsolidatedStatementofShareholdersEquityParenthetical</Role>
      <ShortName>Consolidated Statement of Shareholders' Equity (Parenthetical)</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>9</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R10.htm</HtmlFileName>
      <LongName>0000010 - Disclosure - Summary of Significant Accounting Policies</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/SummaryofSignificantAccountingPolicies</Role>
      <ShortName>Summary of Significant Accounting Policies</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>10</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R11.htm</HtmlFileName>
      <LongName>0000011 - Disclosure - New Pronouncements</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/NewPronouncements</Role>
      <ShortName>New Pronouncements</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>11</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R12.htm</HtmlFileName>
      <LongName>0000012 - Disclosure - Fair Value Measurements</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/FairValueMeasurements</Role>
      <ShortName>Fair Value Measurements</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>12</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R13.htm</HtmlFileName>
      <LongName>0000013 - Disclosure - Cash, Cash Equivalents, and Investments</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/CashCashEquivalentsandInvestments</Role>
      <ShortName>Cash, Cash Equivalents, and Investments</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>13</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R14.htm</HtmlFileName>
      <LongName>0000014 - Disclosure - Inventories</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/Inventories</Role>
      <ShortName>Inventories</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>14</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R15.htm</HtmlFileName>
      <LongName>0000015 - Disclosure - Leases</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/Leases</Role>
      <ShortName>Leases</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>15</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R16.htm</HtmlFileName>
      <LongName>0000016 - Disclosure - Goodwill</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/Goodwill</Role>
      <ShortName>Goodwill</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>16</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R17.htm</HtmlFileName>
      <LongName>0000017 - Disclosure - Intangible Assets</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/IntangibleAssets</Role>
      <ShortName>Intangible Assets</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>17</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R18.htm</HtmlFileName>
      <LongName>0000018 - Disclosure - Warranty Obligations</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/WarrantyObligations</Role>
      <ShortName>Warranty Obligations</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>18</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R19.htm</HtmlFileName>
      <LongName>0000019 - Disclosure - Commitment and Contingencies</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/CommitmentandContingencies</Role>
      <ShortName>Commitment and Contingencies</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>19</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R20.htm</HtmlFileName>
      <LongName>0000020 - Disclosure - Derivative Instruments</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/DerivativeInstruments</Role>
      <ShortName>Derivative Instruments</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>20</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R21.htm</HtmlFileName>
      <LongName>0000021 - Disclosure - Revenue Recognition</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/RevenueRecognition</Role>
      <ShortName>Revenue Recognition</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>21</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R22.htm</HtmlFileName>
      <LongName>0000022 - Disclosure - Stock-Based Compensation Expense</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/StockBasedCompensationExpense</Role>
      <ShortName>Stock-Based Compensation Expense</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>22</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R23.htm</HtmlFileName>
      <LongName>0000023 - Disclosure - Stock Repurchase Program</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/StockRepurchaseProgram</Role>
      <ShortName>Stock Repurchase Program</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>23</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R24.htm</HtmlFileName>
      <LongName>0000024 - Disclosure - Income Taxes</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/IncomeTaxes</Role>
      <ShortName>Income Taxes</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>24</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R25.htm</HtmlFileName>
      <LongName>0000025 - Disclosure - Weighted-Average Shares</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/WeightedAverageShares</Role>
      <ShortName>Weighted-Average Shares</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>25</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R26.htm</HtmlFileName>
      <LongName>0000026 - Disclosure - Loss from Fire</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/LossfromFire</Role>
      <ShortName>Loss from Fire</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>26</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R27.htm</HtmlFileName>
      <LongName>0000027 - Disclosure - Subsequent Events</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/SubsequentEvents</Role>
      <ShortName>Subsequent Events</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>27</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R28.htm</HtmlFileName>
      <LongName>0000028 - Disclosure - Summary of Significant Accounting Policies (Policies)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/SummaryofSignificantAccountingPoliciesPolicies</Role>
      <ShortName>Summary of Significant Accounting Policies (Policies)</ShortName>
      <MenuCategory>Policies</MenuCategory>
      <ParentRole>http://www.cognex.com/role/SummaryofSignificantAccountingPolicies</ParentRole>
      <Position>28</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R29.htm</HtmlFileName>
      <LongName>0000029 - Disclosure - Fair Value Measurements (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/FairValueMeasurementsTables</Role>
      <ShortName>Fair Value Measurements (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.cognex.com/role/FairValueMeasurements</ParentRole>
      <Position>29</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R30.htm</HtmlFileName>
      <LongName>0000030 - Disclosure - Cash, Cash Equivalents, and Investments (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/CashCashEquivalentsandInvestmentsTables</Role>
      <ShortName>Cash, Cash Equivalents, and Investments (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.cognex.com/role/CashCashEquivalentsandInvestments</ParentRole>
      <Position>30</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R31.htm</HtmlFileName>
      <LongName>0000031 - Disclosure - Inventories (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/InventoriesTables</Role>
      <ShortName>Inventories (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.cognex.com/role/Inventories</ParentRole>
      <Position>31</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R32.htm</HtmlFileName>
      <LongName>0000032 - Disclosure - Leases (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/LeasesTables</Role>
      <ShortName>Leases (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.cognex.com/role/Leases</ParentRole>
      <Position>32</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R33.htm</HtmlFileName>
      <LongName>0000033 - Disclosure - Goodwill (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/GoodwillTables</Role>
      <ShortName>Goodwill (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.cognex.com/role/Goodwill</ParentRole>
      <Position>33</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R34.htm</HtmlFileName>
      <LongName>0000034 - Disclosure - Intangible Assets (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/IntangibleAssetsTables</Role>
      <ShortName>Intangible Assets (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.cognex.com/role/IntangibleAssets</ParentRole>
      <Position>34</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R35.htm</HtmlFileName>
      <LongName>0000035 - Disclosure - Warranty Obligations (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/WarrantyObligationsTables</Role>
      <ShortName>Warranty Obligations (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.cognex.com/role/WarrantyObligations</ParentRole>
      <Position>35</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R36.htm</HtmlFileName>
      <LongName>0000036 - Disclosure - Derivative Instruments (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/DerivativeInstrumentsTables</Role>
      <ShortName>Derivative Instruments (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.cognex.com/role/DerivativeInstruments</ParentRole>
      <Position>36</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R37.htm</HtmlFileName>
      <LongName>0000037 - Disclosure - Revenue Recognition (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/RevenueRecognitionTables</Role>
      <ShortName>Revenue Recognition (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.cognex.com/role/RevenueRecognition</ParentRole>
      <Position>37</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R38.htm</HtmlFileName>
      <LongName>0000038 - Disclosure - Stock-Based Compensation Expense (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/StockBasedCompensationExpenseTables</Role>
      <ShortName>Stock-Based Compensation Expense (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.cognex.com/role/StockBasedCompensationExpense</ParentRole>
      <Position>38</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R39.htm</HtmlFileName>
      <LongName>0000039 - Disclosure - Weighted-Average Shares (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/WeightedAverageSharesTables</Role>
      <ShortName>Weighted-Average Shares (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.cognex.com/role/WeightedAverageShares</ParentRole>
      <Position>39</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R40.htm</HtmlFileName>
      <LongName>0000040 - Disclosure - Fair Value Measurements - Assets and Liabilities Measured at Fair Value on a Recurring Basis (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/FairValueMeasurementsAssetsandLiabilitiesMeasuredatFairValueonaRecurringBasisDetails</Role>
      <ShortName>Fair Value Measurements - Assets and Liabilities Measured at Fair Value on a Recurring Basis (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>40</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R41.htm</HtmlFileName>
      <LongName>0000041 - Disclosure - Fair Value Measurements (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/FairValueMeasurementsDetails</Role>
      <ShortName>Fair Value Measurements (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.cognex.com/role/FairValueMeasurementsTables</ParentRole>
      <Position>41</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R42.htm</HtmlFileName>
      <LongName>0000042 - Disclosure - Cash, Cash Equivalents, and Investments (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/CashCashEquivalentsandInvestmentsDetails</Role>
      <ShortName>Cash, Cash Equivalents, and Investments (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.cognex.com/role/CashCashEquivalentsandInvestmentsTables</ParentRole>
      <Position>42</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R43.htm</HtmlFileName>
      <LongName>0000043 - Disclosure - Cash, Cash Equivalents, and Investments - Components of Cash, Cash Equivalents, and Investments (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/CashCashEquivalentsandInvestmentsComponentsofCashCashEquivalentsandInvestmentsDetails</Role>
      <ShortName>Cash, Cash Equivalents, and Investments - Components of Cash, Cash Equivalents, and Investments (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>43</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R44.htm</HtmlFileName>
      <LongName>0000044 - Disclosure - Cash, Cash Equivalents, and Investments - Summary of Available-for-Sale Investments (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/CashCashEquivalentsandInvestmentsSummaryofAvailableforSaleInvestmentsDetails</Role>
      <ShortName>Cash, Cash Equivalents, and Investments - Summary of Available-for-Sale Investments (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>44</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R45.htm</HtmlFileName>
      <LongName>0000045 - Disclosure - Cash, Cash Equivalents, and Investments - Gross Unrealized Losses and Fair Values for Available-for-Sale Investments (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/CashCashEquivalentsandInvestmentsGrossUnrealizedLossesandFairValuesforAvailableforSaleInvestmentsDetails</Role>
      <ShortName>Cash, Cash Equivalents, and Investments - Gross Unrealized Losses and Fair Values for Available-for-Sale Investments (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>45</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R46.htm</HtmlFileName>
      <LongName>0000046 - Disclosure - Cash, Cash Equivalents, and Investments - Effective Maturity Dates of Available-for-Sale Investments (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/CashCashEquivalentsandInvestmentsEffectiveMaturityDatesofAvailableforSaleInvestmentsDetails</Role>
      <ShortName>Cash, Cash Equivalents, and Investments - Effective Maturity Dates of Available-for-Sale Investments (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>46</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R47.htm</HtmlFileName>
      <LongName>0000047 - Disclosure - Inventories - Schedule of Inventories (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/InventoriesScheduleofInventoriesDetails</Role>
      <ShortName>Inventories - Schedule of Inventories (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>47</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R48.htm</HtmlFileName>
      <LongName>0000048 - Disclosure - Leases - Narrative (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/LeasesNarrativeDetails</Role>
      <ShortName>Leases - Narrative (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>48</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R49.htm</HtmlFileName>
      <LongName>0000049 - Disclosure - Leases - Future Minimum Lease Payment Obligations Under Operating Leases (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/LeasesFutureMinimumLeasePaymentObligationsUnderOperatingLeasesDetails</Role>
      <ShortName>Leases - Future Minimum Lease Payment Obligations Under Operating Leases (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>49</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R50.htm</HtmlFileName>
      <LongName>0000050 - Disclosure - Goodwill (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/GoodwillDetails</Role>
      <ShortName>Goodwill (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.cognex.com/role/GoodwillTables</ParentRole>
      <Position>50</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R51.htm</HtmlFileName>
      <LongName>0000051 - Disclosure - Intangible Assets (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/IntangibleAssetsDetails</Role>
      <ShortName>Intangible Assets (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.cognex.com/role/IntangibleAssetsTables</ParentRole>
      <Position>51</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R52.htm</HtmlFileName>
      <LongName>0000052 - Disclosure - Warranty Obligations - Changes in Warranty Obligations (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/WarrantyObligationsChangesinWarrantyObligationsDetail</Role>
      <ShortName>Warranty Obligations - Changes in Warranty Obligations (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>52</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R53.htm</HtmlFileName>
      <LongName>0000053 - Disclosure - Commitment and Contingencies (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/CommitmentandContingenciesDetails</Role>
      <ShortName>Commitment and Contingencies (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.cognex.com/role/CommitmentandContingencies</ParentRole>
      <Position>53</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R54.htm</HtmlFileName>
      <LongName>0000054 - Disclosure - Derivative Instruments (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/DerivativeInstrumentsDetails</Role>
      <ShortName>Derivative Instruments (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.cognex.com/role/DerivativeInstrumentsTables</ParentRole>
      <Position>54</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R55.htm</HtmlFileName>
      <LongName>0000055 - Disclosure - Derivative Instruments - Outstanding Forward Contracts Table (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/DerivativeInstrumentsOutstandingForwardContractsTableDetails</Role>
      <ShortName>Derivative Instruments - Outstanding Forward Contracts Table (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>55</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R56.htm</HtmlFileName>
      <LongName>0000056 - Disclosure - Derivative Instruments - Schedule of Derivative Instruments in Statement of Financial Position, Fair Value (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/DerivativeInstrumentsScheduleofDerivativeInstrumentsinStatementofFinancialPositionFairValueDetails</Role>
      <ShortName>Derivative Instruments - Schedule of Derivative Instruments in Statement of Financial Position, Fair Value (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>56</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R57.htm</HtmlFileName>
      <LongName>0000057 - Disclosure - Derivative Instruments - Offsetting Assets (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/DerivativeInstrumentsOffsettingAssetsDetails</Role>
      <ShortName>Derivative Instruments - Offsetting Assets (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>57</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R58.htm</HtmlFileName>
      <LongName>0000058 - Disclosure - Derivative Instruments - Derivative Instruments, Gain (Loss) (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/DerivativeInstrumentsDerivativeInstrumentsGainLossDetails</Role>
      <ShortName>Derivative Instruments - Derivative Instruments, Gain (Loss) (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>58</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R59.htm</HtmlFileName>
      <LongName>0000059 - Disclosure - Revenue Recognition - Revenue Disaggregated by Geography (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/RevenueRecognitionRevenueDisaggregatedbyGeographyDetails</Role>
      <ShortName>Revenue Recognition - Revenue Disaggregated by Geography (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>59</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R60.htm</HtmlFileName>
      <LongName>0000060 - Disclosure - Revenue Recognition - Revenue Disaggregated by Products and Services (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/RevenueRecognitionRevenueDisaggregatedbyProductsandServicesDetails</Role>
      <ShortName>Revenue Recognition - Revenue Disaggregated by Products and Services (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>60</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R61.htm</HtmlFileName>
      <LongName>0000061 - Disclosure - Revenue Recognition - Additional Information (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/RevenueRecognitionAdditionalInformationDetails</Role>
      <ShortName>Revenue Recognition - Additional Information (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>61</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R62.htm</HtmlFileName>
      <LongName>0000062 - Disclosure - Revenue Recognition - Schedule of Allowance for Credit Loss (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/RevenueRecognitionScheduleofAllowanceforCreditLossDetails</Role>
      <ShortName>Revenue Recognition - Schedule of Allowance for Credit Loss (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>62</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R63.htm</HtmlFileName>
      <LongName>0000063 - Disclosure - Revenue Recognition - Deferred Revenue Activity (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/RevenueRecognitionDeferredRevenueActivityDetails</Role>
      <ShortName>Revenue Recognition - Deferred Revenue Activity (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>63</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R64.htm</HtmlFileName>
      <LongName>0000064 - Disclosure - Stock-Based Compensation Expense (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/StockBasedCompensationExpenseDetails</Role>
      <ShortName>Stock-Based Compensation Expense (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.cognex.com/role/StockBasedCompensationExpenseTables</ParentRole>
      <Position>64</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R65.htm</HtmlFileName>
      <LongName>0000065 - Disclosure - Stock-Based Compensation Expense - Summary of Stock Option Activity (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/StockBasedCompensationExpenseSummaryofStockOptionActivityDetails</Role>
      <ShortName>Stock-Based Compensation Expense - Summary of Stock Option Activity (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>65</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R66.htm</HtmlFileName>
      <LongName>0000066 - Disclosure - Stock-Based Compensation Expense - Weighted-Average Assumptions Used in Estimating Fair Values of Stock Options Granted (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/StockBasedCompensationExpenseWeightedAverageAssumptionsUsedinEstimatingFairValuesofStockOptionsGrantedDetails</Role>
      <ShortName>Stock-Based Compensation Expense - Weighted-Average Assumptions Used in Estimating Fair Values of Stock Options Granted (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>66</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R67.htm</HtmlFileName>
      <LongName>0000067 - Disclosure - Stock-Based Compensation Expense Stock-Based Compensation Expense - Schedule of Restricted Stock Units (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/StockBasedCompensationExpenseStockBasedCompensationExpenseScheduleofRestrictedStockUnitsDetails</Role>
      <ShortName>Stock-Based Compensation Expense Stock-Based Compensation Expense - Schedule of Restricted Stock Units (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>67</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R68.htm</HtmlFileName>
      <LongName>0000068 - Disclosure - Stock-Based Compensation Expense - Schedule of Performance Restricted Stock Units (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/StockBasedCompensationExpenseScheduleofPerformanceRestrictedStockUnitsDetails</Role>
      <ShortName>Stock-Based Compensation Expense - Schedule of Performance Restricted Stock Units (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>68</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R69.htm</HtmlFileName>
      <LongName>0000069 - Disclosure - Stock-Based Compensation Expense - Schedule of Employee Service Share-based Compensation, Allocation of Recognized Period Costs (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/StockBasedCompensationExpenseScheduleofEmployeeServiceSharebasedCompensationAllocationofRecognizedPeriodCostsDetails</Role>
      <ShortName>Stock-Based Compensation Expense - Schedule of Employee Service Share-based Compensation, Allocation of Recognized Period Costs (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>69</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R70.htm</HtmlFileName>
      <LongName>0000070 - Disclosure - Stock Repurchase Program (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/StockRepurchaseProgramDetails</Role>
      <ShortName>Stock Repurchase Program (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.cognex.com/role/StockRepurchaseProgram</ParentRole>
      <Position>70</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R71.htm</HtmlFileName>
      <LongName>0000071 - Disclosure - Income Taxes (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/IncomeTaxesDetails</Role>
      <ShortName>Income Taxes (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.cognex.com/role/IncomeTaxes</ParentRole>
      <Position>71</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R72.htm</HtmlFileName>
      <LongName>0000072 - Disclosure - Weighted-Average Shares - Calculation of Weighted-Average Shares (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/WeightedAverageSharesCalculationofWeightedAverageSharesDetails</Role>
      <ShortName>Weighted-Average Shares - Calculation of Weighted-Average Shares (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>72</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R73.htm</HtmlFileName>
      <LongName>0000073 - Disclosure - Weighted-Average Shares (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/WeightedAverageSharesDetails</Role>
      <ShortName>Weighted-Average Shares (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.cognex.com/role/WeightedAverageSharesTables</ParentRole>
      <Position>73</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R74.htm</HtmlFileName>
      <LongName>0000074 - Disclosure - Loss from Fire (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/LossfromFireDetails</Role>
      <ShortName>Loss from Fire (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.cognex.com/role/LossfromFire</ParentRole>
      <Position>74</Position>
    </Report>
    <Report instance="cgnx-20221002.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R75.htm</HtmlFileName>
      <LongName>0000075 - Disclosure - Subsequent Events (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/SubsequentEventsDetails</Role>
      <ShortName>Subsequent Events (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.cognex.com/role/SubsequentEvents</ParentRole>
      <Position>75</Position>
    </Report>
    <Report>
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <LongName>All Reports</LongName>
      <ReportType>Book</ReportType>
      <ShortName>All Reports</ShortName>
    </Report>
  </MyReports>
  <Logs>
    <Log type="Warning">[ix-0514-Hidden-Fact-Eligible-For-Transform] WARN: 3 fact(s) appearing in ix:hidden were eligible for transformation: us-gaap:ShareBasedCompensationArrangementByShareBasedPaymentAwardAwardVestingPeriod1 -  cgnx-20221002.htm 4</Log>
  </Logs>
  <InputFiles>
    <File doctype="10-Q" original="cgnx-20221002.htm">cgnx-20221002.htm</File>
    <File>a1022022-10qxexhibit311.htm</File>
    <File>a1022022-10qxexhibit312.htm</File>
    <File>a1022022-10qxexhibit321.htm</File>
    <File>a1022022-10qxexhibit322.htm</File>
    <File>cgnx-20221002.xsd</File>
    <File>cgnx-20221002_cal.xml</File>
    <File>cgnx-20221002_def.xml</File>
    <File>cgnx-20221002_lab.xml</File>
    <File>cgnx-20221002_pre.xml</File>
  </InputFiles>
  <SupplementalFiles/>
  <BaseTaxonomies>
    <BaseTaxonomy items="959">http://fasb.org/us-gaap/2022</BaseTaxonomy>
    <BaseTaxonomy items="29">http://xbrl.sec.gov/dei/2022</BaseTaxonomy>
  </BaseTaxonomies>
  <HasPresentationLinkbase>true</HasPresentationLinkbase>
  <HasCalculationLinkbase>true</HasCalculationLinkbase>
</FilingSummary>
