<?xml version='1.0' encoding='utf-8'?>
<FilingSummary>
  <Version>3.21.1</Version>
  <ProcessingTime/>
  <ReportFormat>html</ReportFormat>
  <ContextCount>159</ContextCount>
  <ElementCount>401</ElementCount>
  <EntityCount>1</EntityCount>
  <FootnotesReported>false</FootnotesReported>
  <SegmentCount>68</SegmentCount>
  <ScenarioCount>0</ScenarioCount>
  <TuplesReported>false</TuplesReported>
  <UnitCount>15</UnitCount>
  <MyReports>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R1.htm</HtmlFileName>
      <LongName>0001001 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R2.htm</HtmlFileName>
      <LongName>1001002 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R3.htm</HtmlFileName>
      <LongName>1002003 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R4.htm</HtmlFileName>
      <LongName>1003004 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R5.htm</HtmlFileName>
      <LongName>1004005 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R6.htm</HtmlFileName>
      <LongName>1005006 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R7.htm</HtmlFileName>
      <LongName>1006007 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R8.htm</HtmlFileName>
      <LongName>1007008 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R9.htm</HtmlFileName>
      <LongName>1008009 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R10.htm</HtmlFileName>
      <LongName>2101101 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R11.htm</HtmlFileName>
      <LongName>2103102 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R12.htm</HtmlFileName>
      <LongName>2104103 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R13.htm</HtmlFileName>
      <LongName>2108104 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R14.htm</HtmlFileName>
      <LongName>2116105 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R15.htm</HtmlFileName>
      <LongName>2119106 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R16.htm</HtmlFileName>
      <LongName>2123107 - Disclosure - Goodwill (Notes)</LongName>
      <ReportType>Notes</ReportType>
      <Role>http://www.cognex.com/role/GoodwillNotes</Role>
      <ShortName>Goodwill (Notes)</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>16</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R17.htm</HtmlFileName>
      <LongName>2126108 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R18.htm</HtmlFileName>
      <LongName>2129109 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R19.htm</HtmlFileName>
      <LongName>2132110 - Disclosure - Derivative Instruments</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/DerivativeInstruments</Role>
      <ShortName>Derivative Instruments</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>19</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R20.htm</HtmlFileName>
      <LongName>2139111 - Disclosure - Revenue Recognition</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/RevenueRecognition</Role>
      <ShortName>Revenue Recognition</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>20</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R21.htm</HtmlFileName>
      <LongName>2146112 - 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>21</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R22.htm</HtmlFileName>
      <LongName>2153113 - 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>22</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R23.htm</HtmlFileName>
      <LongName>2155114 - Disclosure - Taxes</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/Taxes</Role>
      <ShortName>Taxes</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>23</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R24.htm</HtmlFileName>
      <LongName>2159115 - 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>24</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R25.htm</HtmlFileName>
      <LongName>2163116 - Disclosure - Restructuring Charges</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/RestructuringCharges</Role>
      <ShortName>Restructuring Charges</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>25</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R26.htm</HtmlFileName>
      <LongName>2167117 - Disclosure - Subsequent Events</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/SubsequentEvents</Role>
      <ShortName>Subsequent Events</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>26</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R27.htm</HtmlFileName>
      <LongName>2202201 - 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>27</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R28.htm</HtmlFileName>
      <LongName>2305301 - 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>28</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R29.htm</HtmlFileName>
      <LongName>2309302 - 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>29</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R30.htm</HtmlFileName>
      <LongName>2317303 - 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>30</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R31.htm</HtmlFileName>
      <LongName>2320304 - 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>31</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R32.htm</HtmlFileName>
      <LongName>2324305 - 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/GoodwillNotes</ParentRole>
      <Position>32</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R33.htm</HtmlFileName>
      <LongName>2327306 - 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>33</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R34.htm</HtmlFileName>
      <LongName>2330307 - 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>34</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R35.htm</HtmlFileName>
      <LongName>2333308 - 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>35</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R36.htm</HtmlFileName>
      <LongName>2340309 - 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>36</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R37.htm</HtmlFileName>
      <LongName>2347310 - 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>37</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R38.htm</HtmlFileName>
      <LongName>2356311 - Disclosure - Income Taxes (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/IncomeTaxesTables</Role>
      <ShortName>Income Taxes (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <Position>38</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R39.htm</HtmlFileName>
      <LongName>2360312 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R40.htm</HtmlFileName>
      <LongName>2364313 - Disclosure - Restructuring Charges (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/RestructuringChargesTables</Role>
      <ShortName>Restructuring Charges (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.cognex.com/role/RestructuringCharges</ParentRole>
      <Position>40</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R41.htm</HtmlFileName>
      <LongName>2406401 - 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>41</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R42.htm</HtmlFileName>
      <LongName>2407402 - 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>42</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R43.htm</HtmlFileName>
      <LongName>2410403 - 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>43</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R44.htm</HtmlFileName>
      <LongName>2411404 - 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>44</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R45.htm</HtmlFileName>
      <LongName>2412405 - 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>45</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R46.htm</HtmlFileName>
      <LongName>2413406 - 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>46</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R47.htm</HtmlFileName>
      <LongName>2415408 - 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>47</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R48.htm</HtmlFileName>
      <LongName>2418409 - 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>48</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R49.htm</HtmlFileName>
      <LongName>2421410 - 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>49</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R50.htm</HtmlFileName>
      <LongName>2422411 - 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>50</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R51.htm</HtmlFileName>
      <LongName>2425412 - 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>51</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R52.htm</HtmlFileName>
      <LongName>2428413 - 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>52</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R53.htm</HtmlFileName>
      <LongName>2431414 - 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>53</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R54.htm</HtmlFileName>
      <LongName>2434415 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R55.htm</HtmlFileName>
      <LongName>2435416 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R56.htm</HtmlFileName>
      <LongName>2436417 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R57.htm</HtmlFileName>
      <LongName>2437418 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R58.htm</HtmlFileName>
      <LongName>2438419 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R59.htm</HtmlFileName>
      <LongName>2441420 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R60.htm</HtmlFileName>
      <LongName>2442421 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R61.htm</HtmlFileName>
      <LongName>2443422 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R62.htm</HtmlFileName>
      <LongName>2444423 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R63.htm</HtmlFileName>
      <LongName>2445424 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R64.htm</HtmlFileName>
      <LongName>2448425 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R65.htm</HtmlFileName>
      <LongName>2449426 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R66.htm</HtmlFileName>
      <LongName>2450427 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R67.htm</HtmlFileName>
      <LongName>2451428 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R68.htm</HtmlFileName>
      <LongName>2452429 - 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>68</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R69.htm</HtmlFileName>
      <LongName>2454430 - 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>69</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R70.htm</HtmlFileName>
      <LongName>2457431 - Disclosure - Income Taxes - Reconciliation of United States Federal Statutory Corporate Tax Rate to Company's Effective Tax Rate, or Income Tax Provision (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/IncomeTaxesReconciliationofUnitedStatesFederalStatutoryCorporateTaxRatetoCompanysEffectiveTaxRateorIncomeTaxProvisionDetails</Role>
      <ShortName>Income Taxes - Reconciliation of United States Federal Statutory Corporate Tax Rate to Company's Effective Tax Rate, or Income Tax Provision (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>70</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R71.htm</HtmlFileName>
      <LongName>2458432 - 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/IncomeTaxesTables</ParentRole>
      <Position>71</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R72.htm</HtmlFileName>
      <LongName>2461433 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R73.htm</HtmlFileName>
      <LongName>2462434 - 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-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R74.htm</HtmlFileName>
      <LongName>2465435 - Disclosure - Restructuring Charges - Narrative (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/RestructuringChargesNarrativeDetails</Role>
      <ShortName>Restructuring Charges - Narrative (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>74</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R75.htm</HtmlFileName>
      <LongName>2466436 - Disclosure - Restructuring Charges - Activity in Restructuring Reserve (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.cognex.com/role/RestructuringChargesActivityinRestructuringReserveDetails</Role>
      <ShortName>Restructuring Charges - Activity in Restructuring Reserve (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>75</Position>
    </Report>
    <Report instance="cgnx-20210404.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R76.htm</HtmlFileName>
      <LongName>2468437 - 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>76</Position>
    </Report>
    <Report>
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <LongName>All Reports</LongName>
      <ReportType>Book</ReportType>
      <ShortName>All Reports</ShortName>
    </Report>
  </MyReports>
  <InputFiles>
    <File doctype="10-Q" original="cgnx-20210404.htm">cgnx-20210404.htm</File>
    <File>a442021-10qxexhibit311.htm</File>
    <File>a442021-10qxexhibit312.htm</File>
    <File>a442021-10qxexhibit321.htm</File>
    <File>a442021-10qxexhibit322.htm</File>
    <File>cgnx-20210404.xsd</File>
    <File>cgnx-20210404_cal.xml</File>
    <File>cgnx-20210404_def.xml</File>
    <File>cgnx-20210404_lab.xml</File>
    <File>cgnx-20210404_pre.xml</File>
  </InputFiles>
  <SupplementalFiles/>
  <BaseTaxonomies>
    <BaseTaxonomy>http://fasb.org/srt/2020-01-31</BaseTaxonomy>
    <BaseTaxonomy>http://xbrl.sec.gov/dei/2020-01-31</BaseTaxonomy>
    <BaseTaxonomy>http://xbrl.sec.gov/country/2020-01-31</BaseTaxonomy>
    <BaseTaxonomy>http://xbrl.sec.gov/currency/2020-01-31</BaseTaxonomy>
    <BaseTaxonomy>http://fasb.org/us-gaap/2020-01-31</BaseTaxonomy>
  </BaseTaxonomies>
  <HasPresentationLinkbase>true</HasPresentationLinkbase>
  <HasCalculationLinkbase>true</HasCalculationLinkbase>
</FilingSummary>
