Charge-coupled device (CCD) spectrometers are widely used as detectors in analytical laboratory instruments and as sensors for in situ optical measurements. However, as the applications become more complex, the physical and electronic limits of the CCD spectrometers may restrict their applicability. The errors due to dark currents, temperature variations, and blooming can be readily corrected. However, a correction for uncertainty of integration time and wavelength calibration is typically lacking in most devices, and detector non-linearity may distort the signal by up to 5% for some measurements. Here, we propose a simple correction method to compensate for non-linearity errors in optical measurements where compact CCD spectrometers are used. The results indicate that the error due to the non-linearity of a spectrometer can be reduced from several hundred counts to about 40 counts if the proposed correction function is applied.