Compact and broadband spectrometers are very useful in various application domains such as agriculture, food, health and security. In minimally-invasive image-guided procedures spectral tissue sensing helps for screening and diagnostic purposes aiming at discriminating between healthy and tumorous tissue at point-of-care locations and outpatient centers. We designed a compact spectrometer based on a three-segment diffraction grating which operates from 300 nm to 1700 nm. The first two segments of the grating cover spectral ranges from ultraviolet to visible and near infrared (UV, VIS/NIR), whereas the third segment covers the short-wave infrared (SWIR) region from 830 nm to 1700 nm. The spectrometer has a resolution of 6 nm in the UV-VIS/NIR ranges and 10 nm in the SWIR range. The smallest signal-to-noise ratio (SNR) of the spectrometer achieved in the VIS range is 650 and in the SWIR range 9300. Afterwards, the designed three-segment grating was fabricated in-house with ultra-precision diamond tooling followed by hot embossing and quantitatively characterized. The experimental results show that the three-segment grating improves the diffraction efficiency in the NIR-SWIR wavelength range by at least a factor of 2 compared to a Richardson grating which only operates from 300 nm to 1100 nm. This result paves the way towards a new approach for making compact and low-cost spectrometers which could be integrated with hand held devices such as tablets and smartphones.