# Inspect sensitive text by using Node.js

Learn how to scan a sample string for sensitive information by using the
Cloud Data Loss Prevention API of Sensitive Data Protection, the Google Cloud CLI, and Node.js.

*** ** * ** ***

To follow step-by-step guidance for this task directly in the
Google Cloud console, click **Guide me**:

[Guide me](https://console.cloud.google.com/freetrial?redirectPath=/?walkthrough_id%3Ddlp--inspect-sensitive-text)

*** ** * ** ***

## Before you begin

1. [Install Node.js and NPM](https://docs.cloud.google.com/nodejs/docs/setup.md.txt).

## Set up a Sensitive Data Protection CLI app

To set up a Sensitive Data Protection CLI app using Node.js, do the following:

1. Clone the [Node.js DLP client library](https://github.com/GoogleCloudPlatform/nodejs-docs-samples):

   ```bash
    git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples
   ```
2. Navigate to the `dlp` directory.

   ```bash
    cd nodejs-docs-samples/dlp
   ```
3. Install the app dependencies:

   ```bash
    npm install
   ```

## Inspect a string for sensitive information

To scan sample text by using the DLP API and the `inspectString`
Node.js script, run the following command:

```bash
  node inspectString.js PROJECT_ID "My email address is joe@example.com."
```

The output is similar to the following:

      Findings:
          Info type: EMAIL_ADDRESS
          Likelihood: LIKELY

## Clean up


To avoid incurring charges to your Google Cloud account for
the resources used on this page, delete the Google Cloud project with the
resources.

### Delete the project

If you created a new project for this quickstart, the easiest way to prevent
additional charges is to delete the project.

> [!CAUTION]
> **Caution** : Deleting a project has the following effects:
>
> - **Everything in the project is deleted.** If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.
> - **Custom project IDs are lost.** When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as an `appspot.com` URL, delete selected resources inside the project instead of deleting the whole project.
>
>
> If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects
> can help you avoid exceeding project quota limits.

1. Delete a Google Cloud project:

```
gcloud projects delete PROJECT_ID
```

<br />

### Revoke your credentials

1.
   Optional: Revoke the authentication credentials that you created, and delete the local
   credential file.

   ```bash
   gcloud auth application-default revoke
   ```
2.
   Optional: Revoke credentials from the gcloud CLI.

   ```bash
   gcloud auth revoke
   ```

## What's next

- To get started with inspecting text and images for sensitive data, see
  [How-to guides](https://docs.cloud.google.com/sensitive-data-protection/docs/how-to).

- To better understand inspection, redaction, infoTypes, and likelihood, see
  [Concepts](https://docs.cloud.google.com/sensitive-data-protection/docs/concepts).

- Learn more about the [DLP API](https://docs.cloud.google.com/sensitive-data-protection/docs/reference/rest/v2).

- Learn more about the [Cloud Data Loss Prevention API Node.js Client](https://docs.cloud.google.com/nodejs/docs/reference/dlp/latest.md.txt).