CSVLint is an online validation tool for CSV files. It validates CSV files for conformity to standards, checks for missing or malformed data, and can validate against both CSV on the Web (CSVW) and Data Package schema standards. CSVLint is developed and maintained by an open-source community, with hosting provided by the Open Data Institute (ODI).
- Structure Validation: Checks CSV files for structural issues, such as inconsistent row lengths, incorrect quoting, and malformed line endings.
- Schema Validation: Validates CSV data against specified schemas, including CSVW and Data Package standards, to ensure that data formats, types, and constraints are met.
- Dialect Options: Provides flexible dialect options for delimiters, quoting characters, line terminators, and other CSV parsing configurations.
- URL and File Upload Validation: Validates CSV files available via URL or directly uploaded.
- Detailed Reporting: Returns detailed feedback on validation results, including errors, warnings, and informational messages.
- Privacy-Focused: Does not store URLs or CSV content after validation. Instead, a one-way hash of URLs is stored to identify previously validated URLs without retaining identifiable data.
Ensure that you have the following installed on your system:
- Node.js (version 14+ recommended)
- MongoDB (for storing validation reports)
- csvlint-api (backend service to talk with the
csvlint
validation ruby gem)
-
Clone the repository:
git clone https://github.com/theodi/csvlint.io cd csvlint
-
Install Node.js dependencies:
npm install
-
Install CSVLint API: Refer to documentation here
-
Set up environment variables: Copy
.env.example
to.env
and set up the environment variables. Key variables include:PORT
: Port on which the server will run.MONGO_URI
: MongoDB URI for storing validation reports.CSVLINT_API
: URL for the CSVLint Ruby server (e.g.,http://localhost:4567/validate
).HOST
: Base URL for accessing the validation service (e.g.,https://csvlint.io
).
-
Start the Node.js server:
npm start
Access the web interface by navigating to https://csvlint.io
(or your configured HOST
and PORT
).
The CSVLint API can be used programmatically to validate CSV files via URLs or direct file uploads.
- POST /validate: Validates a CSV file from a URL or uploaded file.
- GET /validate: Validates a CSV from a URL and returns either a badge or JSON report based on
format
andaccept
headers.
Examples of API usage can be found in the API Documentation.
POST /validate
: Validates a CSV file or URL.GET /validate
: Validates a CSV file from a URL and can return a validation badge.
- csvUrl (string): URL to the CSV file to validate.
- schemaUrl (string): URL to a JSON schema for validation (optional).
- file (file): CSV file upload (optional, if
csvUrl
is provided). - schema (file): JSON schema file upload (optional).
- dialect options: Optional CSV dialect options, such as
delimiter
,lineTerminator
, andquoteChar
.
The API can return a JSON response or validation badge depending on the format
query parameter or accept
header.
Example of a validation report JSON:
{
"version": "0.2",
"licence": "http://opendatacommons.org/licenses/odbl/",
"validation": {
"source": "http://example.com/mydata.csv",
"schema": "http://example.com/myschema.json",
"state": "invalid",
"errors": [{ "type": "undeclared_header", "category": "structure" }]
}
}
To embed a validation badge for a CSV, you can use the following HTML:
<a href="https://csvlint.io/validate?csvUrl=http://example.com/mydata.csv">
<img src="https://csvlint.io/validate?csvUrl=http://example.com/mydata.csv&format=svg" alt="Validation Badge">
</a>
This service is privacy-focused and removes any identifiable information from validation reports. To view a detailed privacy policy, see Privacy Policy.
We welcome contributions! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature.
- Submit a pull request for review.
This project is licensed under the MIT License.