> For the complete documentation index, see [llms.txt](https://npms.gitbook.io/country-info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://npms.gitbook.io/country-info/reference/functions/search-countries.md).

# Search Countries

The **searchCountries** function allows you to search for countries based on a keyword in their names, capitals, or codes. You can specify the fields you want to retrieve as an array.

```javascript
const { searchCountries } = require('countrys-info');

// Search for countries based on a keyword
const countriesByKeyword = searchCountries('united', ['name_en', 'capital_en']);
console.log(countriesByKeyword);
```
