Significance: Functional near-infrared spectroscopy (fNIRS) has been widely used to probe human brain function during task state and resting state. However, the existing analysis toolboxes mainly focus on task activation analysis, few software packages can assist resting-state fNIRS studies. Aim: We aimed to provide a versatile and easy-to-use toolbox to perform analysis for both resting state and task fNIRS. Approach: We developed a MATLAB toolbox called NIRS-KIT that works for both resting-state analysis and task activation detection. Results: NIRS-KIT implements common and necessary processing steps for performing fNIRS data analysis, including data preparation, quality control, preprocessing, individual-level analysis, group-level statistics with several popular statistical models, and multiple comparison correction methods, and finally results visualization. For resting-state fNIRS analysis, functional connectivity analysis, graph theory-based network analysis, and amplitude of low-frequency fluctuations analysis are provided. Additionally, NIRS-KIT also supports activation analysis for task fNIRS. Conclusions: NIRS-KIT offers an open source tool for researchers to analyze resting-state and/or task fNIRS data in one suite. It contains several key features: (1) good compatibility, supporting multiple fNIRS recording systems, data formats of NIRS-SPM and Homer2, and the shared near-infrared spectroscopy format data format recommended by the fNIRS society; (2) flexibility, supporting customized preprocessing scripts; (3) ease-to-use, allowing processing fNIRS signals in batch manner with user-friendly graphical user interfaces; and (4) feature-packed data viewing and result visualization. We anticipate that this NIRS-KIT will facilitate the development of the fNIRS field.