/ docs-website / versioned_docs / version-2.20 / concepts / pipelines / visualizing-pipelines.mdx
visualizing-pipelines.mdx
 1  ---
 2  title: "Visualizing Pipelines"
 3  id: visualizing-pipelines
 4  slug: "/visualizing-pipelines"
 5  description: "You can visualize your pipelines as graphs to better understand how the components are connected."
 6  ---
 7  
 8  import ClickableImage from "@site/src/components/ClickableImage";
 9  
10  # Visualizing Pipelines
11  
12  You can visualize your pipelines as graphs to better understand how the components are connected.
13  
14  Haystack pipelines have  `draw()` and `show()` methods that enable you to visualize the pipeline as a graph using Mermaid graphs.
15  
16  :::note[Data Privacy Notice]
17  
18  Exercise caution with sensitive data when using pipeline visualization.
19  
20  This feature is based on Mermaid graphs web service that doesn't have clear terms of data retention or privacy policy.
21  :::
22  
23  ## Prerequisites
24  
25  To use Mermaid graphs, you must have an internet connection to reach the Mermaid graph renderer at https://mermaid.ink.
26  
27  ## Displaying a Graph
28  
29  Use the pipeline's `show()` method to display the diagram in Jupyter notebooks.
30  
31  ```python
32  my_pipeline.show()
33  ```
34  
35  ## Saving a Graph
36  
37  Use the pipeline's `draw()` method passing the path where you want to save the diagram and the diagram format. Possible formats are:  `mermaid-text` and `mermaid-image` (default).
38  
39  ```python
40  my_pipeline.draw(path=local_path)
41  ```
42  
43  ## Visualizing SuperComponents
44  
45  To show the internal structure of [SuperComponents](../components/supercomponents.mdx) in your digram instead of a black box component, set the `super_component_expansion` parameter to `True`:
46  
47  ```python
48  my_pipeline.show(super_component_expansion=True)
49  
50  ## or
51  
52  my_pipeline.draw(path=local_path, super_component_expansion=True)
53  ```
54  
55  ## Visualizing Locally
56  
57  If you don't have an internet connection or don't want to send your pipeline data to the remote https://mermaid.ink, you can install a local mermaid.ink server and use it to render your pipeline.
58  
59  Let's run a local mermaid.ink server using their official Docker images from https://github.com/jihchi/mermaid.ink/pkgs/container/mermaid.ink.
60  
61  In this case, let's install one for a system running a MacOS M3 chip and expose it on port 3000:
62  
63  ```dockerfile
64  docker run --platform linux/amd64 --publish 3000:3000 --cap-add=SYS_ADMIN ghcr.io/jihchi/mermaid.ink
65  ```
66  
67  Check that the local mermaid.ink server is running by going to http://localhost:3000/.
68  
69  You should see a local server running, and now you can simply render the image using your local mermaid.ink server by specifying the URL when calling the`show()`or `draw()`  method:
70  
71  ```python
72  my_pipeline.show(server_url="http://localhost:3000")
73  ## or
74  my_pipeline.draw("my_pipeline.png", server_url="http://localhost:3000")
75  ```
76  
77  ## Example
78  
79  This is an example of what a pipeline graph may look like:
80  <ClickableImage src="/img/46a8989-Untitled.png" alt="RAG pipeline flowchart showing the data flow from query through retriever, prompt builder, language model, and answer builder components" size="large" />
81  
82  <br />
83  
84  ## Importing a Pipeline to deepset Studio
85  
86  You can import your Haystack pipeline into deepset Studio and continue visually building your pipeline
87  
88  To do that, follow the steps described in our deepset AI Platform [documentation](https://docs.cloud.deepset.ai/docs/import-a-pipeline#import-your-pipeline).